# Global Metrics

path: .metrics.nexits.sum
old: 32.0
new: 9.0
path: .metrics.nexits.average
old: 0.8
new: 1.125
path: .metrics.nargs.sum
old: 72.0
new: 10.0
path: .metrics.nargs.average
old: 1.8
new: 1.25
path: .metrics.cognitive.average
old: 2.325
new: 0.75
path: .metrics.cognitive.sum
old: 93.0
new: 6.0
path: .metrics.cyclomatic.sum
old: 118.0
new: 111.0
path: .metrics.cyclomatic.average
old: 2.4081632653061225
new: 10.090909090909092
path: .metrics.loc.sloc
old: 880.0
new: 359.0
path: .metrics.loc.lloc
old: 282.0
new: 293.0
path: .metrics.loc.blank
old: 126.0
new: 19.0
path: .metrics.loc.cloc
old: 78.0
new: 16.0
path: .metrics.loc.ploc
old: 676.0
new: 324.0
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 1.4445168829767012
path: .metrics.mi.mi_original
old: -20.90061835492594
new: 2.470123869890159
path: .metrics.mi.mi_sei
old: -71.58711474124719
new: -44.772521275320955
path: .metrics.nom.functions
old: 40.0
new: 8.0
path: .metrics.nom.total
old: 40.0
new: 8.0
path: .metrics.halstead.N1
old: 2447.0
new: 824.0
path: .metrics.halstead.bugs
old: 7.714780972089521
new: 1.2175290900711375
path: .metrics.halstead.effort
old: 3521010.199080814
new: 220750.09634995428
path: .metrics.halstead.time
old: 195611.6777267119
new: 12263.894241664128
path: .metrics.halstead.volume
old: 38664.21966825053
new: 9615.812159506206
path: .metrics.halstead.N2
old: 1871.0
new: 427.0
path: .metrics.halstead.length
old: 4318.0
new: 1251.0
path: .metrics.halstead.vocabulary
old: 496.0
new: 206.0
path: .metrics.halstead.level
old: 0.010981001894951657
new: 0.04355971896955504
path: .metrics.halstead.difficulty
old: 91.06637168141592
new: 22.956989247311828
path: .metrics.halstead.purity_ratio
old: 0.9789105794885842
new: 1.1900256600830064
path: .metrics.halstead.estimated_program_length
old: 4226.935882231706
new: 1488.722100763841
path: .metrics.halstead.n2
old: 452.0
new: 186.0
path: .metrics.halstead.n1
old: 44.0
new: 20.0

# Spaces Data

## Minimal test - lines (13, 359)

path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 10.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 17.0
path: .spaces[0].metrics.loc.ploc
old: 2.0
new: 320.0
path: .spaces[0].metrics.loc.sloc
old: 2.0
new: 347.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 293.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 0.75
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 6.0
path: .spaces[0].metrics.mi.mi_sei
old: 138.97000000000003
new: -46.74840974062857
path: .spaces[0].metrics.mi.mi_visual_studio
old: 86.9753916129788
new: 1.9269346911547571
path: .spaces[0].metrics.mi.mi_original
old: 148.72791965819374
new: 3.2950583218746345
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 11.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 110.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 8.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 8.0
path: .spaces[0].metrics.halstead.level
old: 0.6666666666666666
new: 0.04302600472813239
path: .spaces[0].metrics.halstead.time
old: 0.6666666666666666
new: 12310.99573937421
path: .spaces[0].metrics.halstead.volume
old: 8.0
new: 9534.473296025984
path: .spaces[0].metrics.halstead.length
old: 4.0
new: 1245.0
path: .spaces[0].metrics.halstead.n1
old: 3.0
new: 20.0
path: .spaces[0].metrics.halstead.bugs
old: 0.0017471609294725976
new: 1.2206445114497038
path: .spaces[0].metrics.halstead.effort
old: 12.0
new: 221597.92330873577
path: .spaces[0].metrics.halstead.N1
old: 3.0
new: 822.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 4.754887502163468
new: 1452.85718641391
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 182.0
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 423.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.188721875540867
new: 1.1669535633846666
path: .spaces[0].metrics.halstead.vocabulary
old: 4.0
new: 202.0
path: .spaces[0].metrics.halstead.difficulty
old: 1.5
new: 23.24175824175824
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 10.0
path: .spaces[0].metrics.nargs.average
old: 0.0
new: 1.25
path: .spaces[0].metrics.nexits.average
old: 0.0
new: 1.125
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 9.0

### Code

    namespace mozilla {
    namespace widget {

    static const char16_t UNICODE_BULLET = 0x2022;

    HeadlessLookAndFeel::HeadlessLookAndFeel(const LookAndFeelCache* aCache) {}

    HeadlessLookAndFeel::~HeadlessLookAndFeel() = default;

    nsresult HeadlessLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
      // For headless mode, we use GetStandinForNativeColor for everything we can,
      // and hardcoded values for everything else.

      nsresult res = NS_OK;

      switch (aID) {
        // Override the solid black that GetStandinForNativeColor provides for
        // FieldText, to match our behavior under the real GTK.
        case ColorID::Fieldtext:
          aColor = NS_RGB(0x21, 0x21, 0x21);
          break;

        // The rest are not provided by GetStandinForNativeColor.
        case ColorID::IMESelectedRawTextBackground:
        case ColorID::IMESelectedConvertedTextBackground:
        case ColorID::IMERawInputBackground:
        case ColorID::IMEConvertedTextBackground:
          aColor = NS_TRANSPARENT;
          break;
        case ColorID::IMESelectedRawTextForeground:
        case ColorID::IMESelectedConvertedTextForeground:
        case ColorID::IMERawInputForeground:
        case ColorID::IMEConvertedTextForeground:
          aColor = NS_SAME_AS_FOREGROUND_COLOR;
          break;
        case ColorID::IMERawInputUnderline:
        case ColorID::IMEConvertedTextUnderline:
          aColor = NS_40PERCENT_FOREGROUND_COLOR;
          break;
        case ColorID::IMESelectedRawTextUnderline:
        case ColorID::IMESelectedConvertedTextUnderline:
          aColor = NS_SAME_AS_FOREGROUND_COLOR;
          break;
        case ColorID::MozEventreerow:
          aColor = NS_RGB(0xff, 0xff, 0xff);
          break;
        case ColorID::MozGtkInfoBarText:
          aColor = NS_RGB(0x00, 0x00, 0x00);
          break;
        case ColorID::MozMacButtonactivetext:
        case ColorID::MozMacDefaultbuttontext:
          aColor = NS_RGB(0xff, 0xff, 0xff);
          break;
        case ColorID::SpellCheckerUnderline:
          aColor = NS_RGB(0xff, 0x00, 0x00);
          break;
        case ColorID::TextBackground:
          aColor = NS_RGB(0xff, 0xff, 0xff);
          break;
        case ColorID::TextForeground:
          aColor = NS_RGB(0x00, 0x00, 0x00);
          break;
        case ColorID::TextHighlightBackground:
          aColor = NS_RGB(0xef, 0x0f, 0xff);
          break;
        case ColorID::TextHighlightForeground:
          aColor = NS_RGB(0xff, 0xff, 0xff);
          break;
        case ColorID::TextSelectBackground:
          aColor = NS_RGB(0xaa, 0xaa, 0xaa);
          break;
        case ColorID::TextSelectBackgroundAttention:
          aColor = NS_TRANSPARENT;
          break;
        case ColorID::TextSelectBackgroundDisabled:
          aColor = NS_RGB(0xaa, 0xaa, 0xaa);
          break;
        case ColorID::TextSelectForeground:
          GetColor(ColorID::TextSelectBackground, aColor);
          if (aColor == 0x000000)
            aColor = NS_RGB(0xff, 0xff, 0xff);
          else
            aColor = NS_DONT_CHANGE_COLOR;
          break;
        case ColorID::Widget3DHighlight:
          aColor = NS_RGB(0xa0, 0xa0, 0xa0);
          break;
        case ColorID::Widget3DShadow:
          aColor = NS_RGB(0x40, 0x40, 0x40);
          break;
        case ColorID::WidgetBackground:
          aColor = NS_RGB(0xdd, 0xdd, 0xdd);
          break;
        case ColorID::WidgetForeground:
          aColor = NS_RGB(0x00, 0x00, 0x00);
          break;
        case ColorID::WidgetSelectBackground:
          aColor = NS_RGB(0x80, 0x80, 0x80);
          break;
        case ColorID::WidgetSelectForeground:
          aColor = NS_RGB(0x00, 0x00, 0x80);
          break;
        case ColorID::WindowBackground:
          aColor = NS_RGB(0xff, 0xff, 0xff);
          break;
        case ColorID::WindowForeground:
          aColor = NS_RGB(0x00, 0x00, 0x00);
          break;
        default:
          aColor = GetStandinForNativeColor(aID);
          break;
      }

      return res;
    }

    nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
      nsresult res = NS_OK;
      // These values should be sane defaults for headless mode under GTK.
      switch (aID) {
        case IntID::CaretBlinkTime:
          aResult = 567;
          break;
        case IntID::CaretWidth:
          aResult = 1;
          break;
        case IntID::ShowCaretDuringSelection:
          aResult = 0;
          break;
        case IntID::SelectTextfieldsOnKeyFocus:
          aResult = 1;
          break;
        case IntID::SubmenuDelay:
          aResult = 200;
          break;
        case IntID::MenusCanOverlapOSBar:
          aResult = 0;
          break;
        case IntID::UseOverlayScrollbars:
          aResult = 0;
          break;
        case IntID::AllowOverlayScrollbarsOverlap:
          aResult = 0;
          break;
        case IntID::ShowHideScrollbars:
          aResult = 0;
          break;
        case IntID::SkipNavigatingDisabledMenuItem:
          aResult = 1;
          break;
        case IntID::DragThresholdX:
        case IntID::DragThresholdY:
          aResult = 4;
          break;
        case IntID::UseAccessibilityTheme:
          aResult = 0;
          break;
        case IntID::ScrollArrowStyle:
          aResult = eScrollArrow_None;
          break;
        case IntID::ScrollSliderStyle:
          aResult = eScrollThumbStyle_Proportional;
          break;
        case IntID::ScrollButtonLeftMouseButtonAction:
          aResult = 0;
          return NS_OK;
        case IntID::ScrollButtonMiddleMouseButtonAction:
          aResult = 3;
          return NS_OK;
        case IntID::ScrollButtonRightMouseButtonAction:
          aResult = 3;
          return NS_OK;
        case IntID::TreeOpenDelay:
          aResult = 1000;
          break;
        case IntID::TreeCloseDelay:
          aResult = 1000;
          break;
        case IntID::TreeLazyScrollDelay:
          aResult = 150;
          break;
        case IntID::TreeScrollDelay:
          aResult = 100;
          break;
        case IntID::TreeScrollLinesMax:
          aResult = 3;
          break;
        case IntID::TabFocusModel:
          aResult = nsIContent::eTabFocus_textControlsMask;
          break;
        case IntID::ChosenMenuItemsShouldBlink:
          aResult = 1;
          break;
        case IntID::WindowsAccentColorInTitlebar:
        case IntID::WindowsDefaultTheme:
        case IntID::DWMCompositor:
          aResult = 0;
          res = NS_ERROR_NOT_IMPLEMENTED;
          break;
        case IntID::WindowsClassic:
        case IntID::WindowsGlass:
          aResult = 0;
          res = NS_ERROR_FAILURE;
          break;
        case IntID::TouchEnabled:
        case IntID::MacGraphiteTheme:
        case IntID::MacBigSurTheme:
          aResult = 0;
          res = NS_ERROR_NOT_IMPLEMENTED;
          break;
        case IntID::AlertNotificationOrigin:
          aResult = NS_ALERT_TOP;
          break;
        case IntID::ScrollToClick:
          aResult = 0;
          break;
        case IntID::IMERawInputUnderlineStyle:
        case IntID::IMESelectedRawTextUnderlineStyle:
        case IntID::IMEConvertedTextUnderlineStyle:
        case IntID::IMESelectedConvertedTextUnderline:
          aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
          break;
        case IntID::SpellCheckerUnderlineStyle:
          aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED;
          break;
        case IntID::MenuBarDrag:
          aResult = 0;
          break;
        case IntID::WindowsThemeIdentifier:
        case IntID::OperatingSystemVersionIdentifier:
          aResult = 0;
          res = NS_ERROR_NOT_IMPLEMENTED;
          break;
        case IntID::ScrollbarButtonAutoRepeatBehavior:
          aResult = 0;
          break;
        case IntID::TooltipDelay:
          aResult = 500;
          break;
        case IntID::SwipeAnimationEnabled:
          aResult = 0;
          break;
        case IntID::ScrollbarDisplayOnMouseMove:
          aResult = 0;
          break;
        case IntID::ScrollbarFadeBeginDelay:
          aResult = 0;
          break;
        case IntID::ScrollbarFadeDuration:
          aResult = 0;
          break;
        case IntID::ContextMenuOffsetVertical:
          aResult = -6;
          break;
        case IntID::ContextMenuOffsetHorizontal:
          aResult = 1;
          break;
        case IntID::GTKCSDAvailable:
        case IntID::GTKCSDHideTitlebarByDefault:
        case IntID::GTKCSDTransparentBackground:
          aResult = 0;
          break;
        case IntID::GTKCSDMinimizeButton:
          aResult = 0;
          break;
        case IntID::GTKCSDMaximizeButton:
          aResult = 0;
          break;
        case IntID::GTKCSDCloseButton:
          aResult = 1;
          break;
        case IntID::GTKCSDReversedPlacement:
          aResult = 0;
          break;
        case IntID::SystemUsesDarkTheme:
          aResult = 0;
          break;
        case IntID::PrefersReducedMotion:
          aResult = 0;
          break;
        case IntID::PrimaryPointerCapabilities:
          aResult = 0;
          break;
        case IntID::AllPointerCapabilities:
          aResult = 0;
          break;
        default:
          NS_WARNING(
              "HeadlessLookAndFeel::NativeGetInt called with an unrecognized aID");
          aResult = 0;
          res = NS_ERROR_FAILURE;
          break;
      }
      return res;
    }

    nsresult HeadlessLookAndFeel::NativeGetFloat(FloatID aID, float& aResult) {
      nsresult res = NS_OK;

      // Hardcoded values for GTK.
      switch (aID) {
        case FloatID::IMEUnderlineRelativeSize:
          aResult = 1.0f;
          break;
        case FloatID::SpellCheckerUnderlineRelativeSize:
          aResult = 1.0f;
          break;
        case FloatID::CaretAspectRatio:
          // Intentionally failing to quietly indicate lack of support.
          aResult = -1.0;
          res = NS_ERROR_FAILURE;
          break;
        default:
          NS_WARNING(
              "HeadlessLookAndFeel::NativeGetFloat called with an unrecognized "
              "aID");
          aResult = -1.0;
          res = NS_ERROR_FAILURE;
          break;
      }

      return res;
    }

    bool HeadlessLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName,
                                            gfxFontStyle& aFontStyle) {
      // Default to san-serif for everything.
      aFontStyle.style = FontSlantStyle::Normal();
      aFontStyle.weight = FontWeight::Normal();
      aFontStyle.stretch = FontStretch::Normal();
      aFontStyle.size = 14;
      aFontStyle.systemFont = true;

      aFontName.AssignLiteral("sans-serif");
      return true;
    }

    char16_t HeadlessLookAndFeel::GetPasswordCharacterImpl() {
      return UNICODE_BULLET;
    }

    void HeadlessLookAndFeel::RefreshImpl() { nsXPLookAndFeel::RefreshImpl(); }

    bool HeadlessLookAndFeel::GetEchoPasswordImpl() { return false; }

    }  // namespace widget
    }  // namespace mozilla