# Global Metrics

path: .metrics.loc.ploc
old: 12.0
new: 319.0
path: .metrics.loc.blank
old: 5.0
new: 16.0
path: .metrics.loc.lloc
old: 1.0
new: 217.0
path: .metrics.loc.sloc
old: 75.0
new: 343.0
path: .metrics.loc.cloc
old: 58.0
new: 8.0
path: .metrics.cyclomatic.sum
old: 4.0
new: 110.0
path: .metrics.cyclomatic.average
old: 1.0
new: 7.857142857142857
path: .metrics.mi.mi_original
old: 74.3436048121637
new: 2.8038475958376807
path: .metrics.mi.mi_sei
old: 80.87926747417606
new: -48.7359311563288
path: .metrics.mi.mi_visual_studio
old: 43.47579228781503
new: 1.6396769566302227
path: .metrics.halstead.time
old: 59.42651130470124
new: 21873.90719946621
path: .metrics.halstead.vocabulary
old: 20.0
new: 289.0
path: .metrics.halstead.estimated_program_length
old: 66.43856189774725
new: 2208.6508160332037
path: .metrics.halstead.bugs
old: 0.03486426967756468
new: 1.7906525500775494
path: .metrics.halstead.volume
old: 142.62362713128297
new: 10864.476232043402
path: .metrics.halstead.N1
old: 18.0
new: 803.0
path: .metrics.halstead.length
old: 33.0
new: 1329.0
path: .metrics.halstead.level
old: 0.13333333333333333
new: 0.027593699076588808
path: .metrics.halstead.n1
old: 10.0
new: 35.0
path: .metrics.halstead.effort
old: 1069.6772034846224
new: 393730.32959039183
path: .metrics.halstead.difficulty
old: 7.5
new: 36.24015748031496
path: .metrics.halstead.purity_ratio
old: 2.0132897544771895
new: 1.661889252094209
path: .metrics.halstead.n2
old: 10.0
new: 254.0
path: .metrics.halstead.N2
old: 15.0
new: 526.0
path: .metrics.nom.total
old: 1.0
new: 11.0
path: .metrics.nom.functions
old: 1.0
new: 11.0
path: .metrics.cognitive.sum
old: 0.0
new: 38.0
path: .metrics.cognitive.average
old: 0.0
new: 3.4545454545454546
path: .metrics.nargs.sum
old: 1.0
new: 4.0
path: .metrics.nargs.average
old: 1.0
new: 0.3636363636363637
path: .metrics.nexits.average
old: 1.0
new: 5.545454545454546
path: .metrics.nexits.sum
old: 1.0
new: 61.0

# Spaces Data

## Minimal test - lines (18, 51)

path: .spaces[0].spaces[0].metrics.nargs.average
old: 1.0
new: 3.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 1.0
new: 3.0
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 13.0
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 1.0
new: 13.0
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 112.49418057428524
new: 45.88107952466055
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 100.6890545217925
new: 74.25670799228484
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 58.88248802444006
new: 43.42497543408471
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.13333333333333333
new: 0.022588235294117645
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 12.0
new: 85.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.9730786534094351
new: 1.1085073762827249
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 906.9586878137028
new: 50707.84827966548
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 7.5
new: 44.270833333333336
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 10.0
new: 25.0
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 18.0
new: 49.0
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 57.219280948873624
new: 226.13550476167583
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.03123228426587729
new: 0.45666269300853657
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 17.0
new: 119.0
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 120.92782504182703
new: 1145.4008081995023
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 8.0
new: 24.0
path: .spaces[0].spaces[0].metrics.halstead.time
old: 50.38659376742794
new: 2817.102682203638
path: .spaces[0].spaces[0].metrics.halstead.length
old: 29.0
new: 204.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 0.0
new: 18.0
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 0.0
new: 18.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 16.0
new: 34.0
path: .spaces[0].spaces[0].metrics.loc.cloc
old: 7.0
new: 1.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 1.0
new: 17.0
path: .spaces[0].spaces[0].metrics.loc.blank
old: 3.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 6.0
new: 34.0

### Code

    PrintStringDetail::PrintStringDetail(const nsAString& aString,
                                         uint32_t aMaxLength /* = UINT32_MAX */) {
      Assign("\"");
      const uint32_t kFirstHalf =
          aString.Length() <= aMaxLength ? UINT32_MAX : (aMaxLength + 1) / 2;
      const uint32_t kSecondHalf =
          aString.Length() <= aMaxLength ? 0 : aMaxLength / 2;
      for (uint32_t i = 0; i < aString.Length(); i++) {
        if (i > 0) {
          Append(" ");
        }
        char32_t ch = aString.CharAt(i);
        if (NS_IS_HIGH_SURROGATE(ch) && i + 1 < aString.Length() &&
            NS_IS_LOW_SURROGATE(aString.CharAt(i + 1))) {
          ch = SURROGATE_TO_UCS4(ch, aString.CharAt(i + 1));
        }
        Append(PrintCharData(ch));
        if (i + 1 == kFirstHalf) {
          Append(" ...");
          i = aString.Length() - kSecondHalf - 1;
          if (NS_IS_LOW_SURROGATE(aString.CharAt(i)) &&
              NS_IS_HIGH_SURROGATE(aString.CharAt(i - 1))) {
            if (i - 1 <= kFirstHalf) {
              i++;
            } else {
              i--;
            }
          }
        } else if (!IS_IN_BMP(ch)) {
          i++;
        }
      }
      Append("\"");
    }

## Minimal test - lines (16, 343)

path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 38.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 3.4545454545454546
path: .spaces[0].metrics.nom.total
old: 1.0
new: 11.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 11.0
path: .spaces[0].metrics.halstead.N2
old: 13.0
new: 521.0
path: .spaces[0].metrics.halstead.difficulty
old: 7.222222222222222
new: 36.61646586345382
path: .spaces[0].metrics.halstead.length
old: 31.0
new: 1324.0
path: .spaces[0].metrics.halstead.level
old: 0.13846153846153847
new: 0.0273101179051275
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.9918905148985304
new: 1.6326022557991131
path: .spaces[0].metrics.halstead.vocabulary
old: 19.0
new: 284.0
path: .spaces[0].metrics.halstead.n2
old: 9.0
new: 249.0
path: .spaces[0].metrics.halstead.volume
old: 131.68575291675114
new: 10790.265186224198
path: .spaces[0].metrics.halstead.effort
old: 951.0637710654248
new: 395101.37684899254
path: .spaces[0].metrics.halstead.time
old: 52.83687617030139
new: 21950.076491610696
path: .spaces[0].metrics.halstead.estimated_program_length
old: 61.74860596185444
new: 2161.565386678026
path: .spaces[0].metrics.halstead.N1
old: 18.0
new: 803.0
path: .spaces[0].metrics.halstead.bugs
old: 0.03223679351938164
new: 1.794807079961433
path: .spaces[0].metrics.halstead.n1
old: 10.0
new: 35.0
path: .spaces[0].metrics.nargs.average
old: 1.0
new: 0.3636363636363637
path: .spaces[0].metrics.nargs.sum
old: 1.0
new: 4.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 57.372983458608125
new: 2.218655814178945
path: .spaces[0].metrics.mi.mi_original
old: 98.10780171421987
new: 3.793901442245996
path: .spaces[0].metrics.mi.mi_sei
old: 109.0809887821054
new: -51.74814515127345
path: .spaces[0].metrics.loc.sloc
old: 18.0
new: 328.0
path: .spaces[0].metrics.loc.blank
old: 2.0
new: 12.0
path: .spaces[0].metrics.loc.cloc
old: 8.0
new: 3.0
path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 217.0
path: .spaces[0].metrics.loc.ploc
old: 8.0
new: 313.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 8.384615384615385
path: .spaces[0].metrics.cyclomatic.sum
old: 3.0
new: 109.0
path: .spaces[0].metrics.nexits.sum
old: 1.0
new: 61.0
path: .spaces[0].metrics.nexits.average
old: 1.0
new: 5.545454545454546

### Code

    namespace mozilla {

    PrintStringDetail::PrintStringDetail(const nsAString& aString,
                                         uint32_t aMaxLength /* = UINT32_MAX */) {
      Assign("\"");
      const uint32_t kFirstHalf =
          aString.Length() <= aMaxLength ? UINT32_MAX : (aMaxLength + 1) / 2;
      const uint32_t kSecondHalf =
          aString.Length() <= aMaxLength ? 0 : aMaxLength / 2;
      for (uint32_t i = 0; i < aString.Length(); i++) {
        if (i > 0) {
          Append(" ");
        }
        char32_t ch = aString.CharAt(i);
        if (NS_IS_HIGH_SURROGATE(ch) && i + 1 < aString.Length() &&
            NS_IS_LOW_SURROGATE(aString.CharAt(i + 1))) {
          ch = SURROGATE_TO_UCS4(ch, aString.CharAt(i + 1));
        }
        Append(PrintCharData(ch));
        if (i + 1 == kFirstHalf) {
          Append(" ...");
          i = aString.Length() - kSecondHalf - 1;
          if (NS_IS_LOW_SURROGATE(aString.CharAt(i)) &&
              NS_IS_HIGH_SURROGATE(aString.CharAt(i - 1))) {
            if (i - 1 <= kFirstHalf) {
              i++;
            } else {
              i--;
            }
          }
        } else if (!IS_IN_BMP(ch)) {
          i++;
        }
      }
      Append("\"");
    }

    // static
    nsCString PrintStringDetail::PrintCharData(char32_t aChar) {
      switch (aChar) {
        case 0x0000:
          return "NULL (0x0000)"_ns;
        case 0x0008:
          return "BACKSPACE (0x0008)"_ns;
        case 0x0009:
          return "CHARACTER TABULATION (0x0009)"_ns;
        case 0x000A:
          return "LINE FEED (0x000A)"_ns;
        case 0x000B:
          return "LINE TABULATION (0x000B)"_ns;
        case 0x000C:
          return "FORM FEED (0x000C)"_ns;
        case 0x000D:
          return "CARRIAGE RETURN (0x000D)"_ns;
        case 0x0018:
          return "CANCEL (0x0018)"_ns;
        case 0x001B:
          return "ESCAPE (0x001B)"_ns;
        case 0x0020:
          return "SPACE (0x0020)"_ns;
        case 0x007F:
          return "DELETE (0x007F)"_ns;
        case 0x00A0:
          return "NO-BREAK SPACE (0x00A0)"_ns;
        case 0x00AD:
          return "SOFT HYPHEN (0x00AD)"_ns;
        case 0x2000:
          return "EN QUAD (0x2000)"_ns;
        case 0x2001:
          return "EM QUAD (0x2001)"_ns;
        case 0x2002:
          return "EN SPACE (0x2002)"_ns;
        case 0x2003:
          return "EM SPACE (0x2003)"_ns;
        case 0x2004:
          return "THREE-PER-EM SPACE (0x2004)"_ns;
        case 0x2005:
          return "FOUR-PER-EM SPACE (0x2005)"_ns;
        case 0x2006:
          return "SIX-PER-EM SPACE (0x2006)"_ns;
        case 0x2007:
          return "FIGURE SPACE (0x2007)"_ns;
        case 0x2008:
          return "PUNCTUATION SPACE (0x2008)"_ns;
        case 0x2009:
          return "THIN SPACE (0x2009)"_ns;
        case 0x200A:
          return "HAIR SPACE (0x200A)"_ns;
        case 0x200B:
          return "ZERO WIDTH SPACE (0x200B)"_ns;
        case 0x200C:
          return "ZERO WIDTH NON-JOINER (0x200C)"_ns;
        case 0x200D:
          return "ZERO WIDTH JOINER (0x200D)"_ns;
        case 0x200E:
          return "LEFT-TO-RIGHT MARK (0x200E)"_ns;
        case 0x200F:
          return "RIGHT-TO-LEFT MARK (0x200F)"_ns;
        case 0x2029:
          return "PARAGRAPH SEPARATOR (0x2029)"_ns;
        case 0x202A:
          return "LEFT-TO-RIGHT EMBEDDING (0x202A)"_ns;
        case 0x202B:
          return "RIGHT-TO-LEFT EMBEDDING (0x202B)"_ns;
        case 0x202D:
          return "LEFT-TO-RIGHT OVERRIDE (0x202D)"_ns;
        case 0x202E:
          return "RIGHT-TO-LEFT OVERRIDE (0x202E)"_ns;
        case 0x202F:
          return "NARROW NO-BREAK SPACE (0x202F)"_ns;
        case 0x205F:
          return "MEDIUM MATHEMATICAL SPACE (0x205F)"_ns;
        case 0x2060:
          return "WORD JOINER (0x2060)"_ns;
        case 0x2066:
          return "LEFT-TO-RIGHT ISOLATE (0x2066)"_ns;
        case 0x2067:
          return "RIGHT-TO-LEFT ISOLATE (0x2067)"_ns;
        case 0x3000:
          return "IDEOGRAPHIC SPACE (0x3000)"_ns;
        case 0xFEFF:
          return "ZERO WIDTH NO-BREAK SPACE (0xFEFF)"_ns;
        default: {
          if (aChar < ' ' || (aChar >= 0x80 && aChar < 0xA0)) {
            return nsPrintfCString("Control (0x%04X)", aChar);
          }
          if (NS_IS_HIGH_SURROGATE(aChar)) {
            return nsPrintfCString("High Surrogate (0x%04X)", aChar);
          }
          if (NS_IS_LOW_SURROGATE(aChar)) {
            return nsPrintfCString("Low Surrogate (0x%04X)", aChar);
          }
          if (gfxFontUtils::IsVarSelector(aChar)) {
            return IS_IN_BMP(aChar)
                       ? nsPrintfCString("Variant Selector (0x%04X)", aChar)
                       : nsPrintfCString("Variant Selector (0x%08X)", aChar);
          }
          nsAutoString utf16Str;
          AppendUCS4ToUTF16(aChar, utf16Str);
          return IS_IN_BMP(aChar)
                     ? nsPrintfCString("'%s' (0x%04X)",
                                       NS_ConvertUTF16toUTF8(utf16Str).get(), aChar)
                     : nsPrintfCString("'%s' (0x%08X)",
                                       NS_ConvertUTF16toUTF8(utf16Str).get(),
                                       aChar);
        }
      }
    }

    namespace widget {

    std::ostream& operator<<(std::ostream& aStream, const IMEEnabled& aEnabled) {
      switch (aEnabled) {
        case IMEEnabled::Disabled:
          return aStream << "DISABLED";
        case IMEEnabled::Enabled:
          return aStream << "ENABLED";
        case IMEEnabled::Password:
          return aStream << "PASSWORD";
        case IMEEnabled::Unknown:
          return aStream << "illegal value";
      }
      MOZ_ASSERT_UNREACHABLE("Add a case to handle your new IMEEnabled value");
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream, const IMEState::Open& aOpen) {
      switch (aOpen) {
        case IMEState::DONT_CHANGE_OPEN_STATE:
          aStream << "DONT_CHANGE_OPEN_STATE";
          break;
        case IMEState::OPEN:
          aStream << "OPEN";
          break;
        case IMEState::CLOSED:
          aStream << "CLOSED";
          break;
        default:
          aStream << "illegal value";
          break;
      }
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream, const IMEState& aState) {
      aStream << "{ mEnabled=" << aState.mEnabled << ", mOpen=" << aState.mOpen
              << " }";
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream,
                             const InputContext::Origin& aOrigin) {
      switch (aOrigin) {
        case InputContext::ORIGIN_MAIN:
          aStream << "ORIGIN_MAIN";
          break;
        case InputContext::ORIGIN_CONTENT:
          aStream << "ORIGIN_CONTENT";
          break;
        default:
          aStream << "illegal value";
          break;
      }
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream, const InputContext& aContext) {
      aStream << "{ mIMEState=" << aContext.mIMEState
              << ", mOrigin=" << aContext.mOrigin << ", mHTMLInputType=\""
              << aContext.mHTMLInputType << "\", mHTMLInputInputmode=\""
              << aContext.mHTMLInputInputmode << "\", mActionHint=\""
              << aContext.mActionHint << "\", mAutocapitalize=\""
              << aContext.mAutocapitalize << "\", mMayBeIMEUnaware="
              << (aContext.mMayBeIMEUnaware ? "true" : "false")
              << ", mIsPrivateBrowsing="
              << (aContext.mInPrivateBrowsing ? "true" : "false") << " }";
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream,
                             const InputContextAction::Cause& aCause) {
      switch (aCause) {
        case InputContextAction::CAUSE_UNKNOWN:
          aStream << "CAUSE_UNKNOWN";
          break;
        case InputContextAction::CAUSE_UNKNOWN_CHROME:
          aStream << "CAUSE_UNKNOWN_CHROME";
          break;
        case InputContextAction::CAUSE_KEY:
          aStream << "CAUSE_KEY";
          break;
        case InputContextAction::CAUSE_MOUSE:
          aStream << "CAUSE_MOUSE";
          break;
        case InputContextAction::CAUSE_TOUCH:
          aStream << "CAUSE_TOUCH";
          break;
        case InputContextAction::CAUSE_LONGPRESS:
          aStream << "CAUSE_LONGPRESS";
          break;
        case InputContextAction::CAUSE_UNKNOWN_DURING_NON_KEYBOARD_INPUT:
          aStream << "CAUSE_UNKNOWN_DURING_NON_KEYBOARD_INPUT";
          break;
        case InputContextAction::CAUSE_UNKNOWN_DURING_KEYBOARD_INPUT:
          aStream << "CAUSE_UNKNOWN_DURING_KEYBOARD_INPUT";
          break;
        default:
          aStream << "illegal value";
          break;
      }
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream,
                             const InputContextAction::FocusChange& aFocusChange) {
      switch (aFocusChange) {
        case InputContextAction::FOCUS_NOT_CHANGED:
          aStream << "FOCUS_NOT_CHANGED";
          break;
        case InputContextAction::GOT_FOCUS:
          aStream << "GOT_FOCUS";
          break;
        case InputContextAction::LOST_FOCUS:
          aStream << "LOST_FOCUS";
          break;
        case InputContextAction::MENU_GOT_PSEUDO_FOCUS:
          aStream << "MENU_GOT_PSEUDO_FOCUS";
          break;
        case InputContextAction::MENU_LOST_PSEUDO_FOCUS:
          aStream << "MENU_LOST_PSEUDO_FOCUS";
          break;
        case InputContextAction::WIDGET_CREATED:
          aStream << "WIDGET_CREATED";
          break;
        default:
          aStream << "illegal value";
          break;
      }
      return aStream;
    }

    std::ostream& operator<<(
        std::ostream& aStream,
        const IMENotification::SelectionChangeDataBase& aData) {
      if (!aData.IsValid()) {
        aStream << "{ IsValid()=false }";
        return aStream;
      }
      aStream << "{ mOffset=" << aData.mOffset;
      if (aData.mString->Length() > 20) {
        aStream << ", mString.Length()=" << aData.mString->Length();
      } else {
        aStream << ", mString=\"" << NS_ConvertUTF16toUTF8(*aData.mString)
                << "\" (Length()=" << aData.mString->Length() << ")";
      }

      aStream << ", GetWritingMode()=" << aData.GetWritingMode()
              << ", mReversed=" << (aData.mReversed ? "true" : "false")
              << ", mCausedByComposition="
              << (aData.mCausedByComposition ? "true" : "false")
              << ", mCausedBySelectionEvent="
              << (aData.mCausedBySelectionEvent ? "true" : "false")
              << ", mOccurredDuringComposition="
              << (aData.mOccurredDuringComposition ? "true" : "false") << " }";
      return aStream;
    }

    std::ostream& operator<<(std::ostream& aStream,
                             const IMENotification::TextChangeDataBase& aData) {
      if (!aData.IsValid()) {
        aStream << "{ IsValid()=false }";
        return aStream;
      }
      aStream << "{ mStartOffset=" << aData.mStartOffset
              << ", mRemoveEndOffset=" << aData.mRemovedEndOffset
              << ", mAddedEndOffset=" << aData.mAddedEndOffset
              << ", mCausedOnlyByComposition="
              << (aData.mCausedOnlyByComposition ? "true" : "false")
              << ", mIncludingChangesDuringComposition="
              << (aData.mIncludingChangesDuringComposition ? "true" : "false")
              << ", mIncludingChangesWithoutComposition="
              << (aData.mIncludingChangesWithoutComposition ? "true" : "false")
              << " }";
      return aStream;
    }

    }  // namespace widget
    }  // namespace mozilla