Global Metrics

path: .metrics.loc.blank
old: 11.0
new: 82.0

path: .metrics.loc.lloc
old: 10.0
new: 201.0

path: .metrics.loc.sloc
old: 51.0
new: 588.0

path: .metrics.loc.cloc
old: 6.0
new: 98.0

path: .metrics.loc.ploc
old: 34.0
new: 408.0

path: .metrics.cyclomatic.sum
old: 11.0
new: 101.0

path: .metrics.cyclomatic.average
old: 1.1
new: 2.9705882352941178

path: .metrics.halstead.vocabulary
old: 51.0
new: 230.0

path: .metrics.halstead.difficulty
old: 15.272727272727272
new: 70.06878306878306

path: .metrics.halstead.purity_ratio
old: 1.4727052192975034
new: 0.9751173568108362

path: .metrics.halstead.effort
old: 14207.878456545332
new: 929583.183297428

path: .metrics.halstead.length
old: 164.0
new: 1691.0

path: .metrics.halstead.N2
old: 56.0
new: 646.0

path: .metrics.halstead.time
old: 789.3265809191851
new: 51643.51018319044

path: .metrics.halstead.n2
old: 33.0
new: 189.0

path: .metrics.halstead.estimated_program_length
old: 241.52365596479055
new: 1648.923450367124

path: .metrics.halstead.n1
old: 18.0
new: 41.0

path: .metrics.halstead.N1
old: 108.0
new: 1045.0

path: .metrics.halstead.volume
old: 930.2777560833252
new: 13266.723676146938

path: .metrics.halstead.level
old: 0.06547619047619048
new: 0.014271690704523145

path: .metrics.halstead.bugs
old: 0.19553817946565671
new: 3.1749550733633516

path: .metrics.mi.mi_sei
old: 50.63251685260056
new: -42.9250635730537

path: .metrics.mi.mi_visual_studio
old: 40.485328707020386
new: 0.0

path: .metrics.mi.mi_original
old: 69.22991208900487
new: -4.896650394877156

path: .metrics.nexits.average
old: 0.8888888888888888
new: 0.9333333333333332

path: .metrics.nexits.sum
old: 8.0
new: 28.0

path: .metrics.nom.total
old: 9.0
new: 30.0

path: .metrics.nom.functions
old: 9.0
new: 30.0

path: .metrics.nargs.average
old: 0.2222222222222222
new: 1.4

path: .metrics.nargs.sum
old: 2.0
new: 42.0

path: .metrics.cognitive.sum
old: 1.0
new: 77.0

path: .metrics.cognitive.average
old: 0.1111111111111111
new: 2.566666666666667

Spaces Data

Minimal test - lines (297, 307)

path: .spaces[6].metrics.mi.mi_original
old: 134.75620253769355
new: 103.13356801929834

path: .spaces[6].metrics.mi.mi_sei
old: 118.81307299755096
new: 73.19125499801804

path: .spaces[6].metrics.mi.mi_visual_studio
old: 78.80479680566874
new: 60.31202808146102

path: .spaces[6].metrics.halstead.difficulty
old: 3.5
new: 9.0

path: .spaces[6].metrics.halstead.length
old: 10.0
new: 54.0

path: .spaces[6].metrics.halstead.n1
old: 7.0
new: 12.0

path: .spaces[6].metrics.halstead.volume
old: 33.219280948873624
new: 253.82374477961895

path: .spaces[6].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 1.7837503503233394

path: .spaces[6].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.05781784710880271

path: .spaces[6].metrics.halstead.N1
old: 7.0
new: 33.0

path: .spaces[6].metrics.halstead.level
old: 0.2857142857142857
new: 0.1111111111111111

path: .spaces[6].metrics.halstead.n2
old: 3.0
new: 14.0

path: .spaces[6].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 96.32251891746031

path: .spaces[6].metrics.halstead.vocabulary
old: 10.0
new: 26.0

path: .spaces[6].metrics.halstead.time
old: 6.459304628947649
new: 126.91187238980947

path: .spaces[6].metrics.halstead.N2
old: 3.0
new: 21.0

path: .spaces[6].metrics.halstead.effort
old: 116.26748332105768
new: 2284.4137030165707

path: .spaces[6].metrics.loc.blank
old: 0.0
new: 1.0

path: .spaces[6].metrics.loc.sloc
old: 3.0
new: 11.0

path: .spaces[6].metrics.loc.lloc
old: 1.0
new: 3.0

path: .spaces[6].metrics.loc.ploc
old: 3.0
new: 10.0

path: .spaces[6].metrics.nargs.average
old: 0.0
new: 6.0

path: .spaces[6].metrics.nargs.sum
old: 0.0
new: 6.0

Code

nsresult nsPropertiesParser::SegmentWriter(nsIUnicharInputStream* aStream,
                                           void* aClosure,
                                           const char16_t* aFromSegment,
                                           uint32_t aToOffset, uint32_t aCount,
                                           uint32_t* aWriteCount) {
  nsPropertiesParser* parser = static_cast(aClosure);
  parser->ParseBuffer(aFromSegment, aCount);

  *aWriteCount = aCount;
  return NS_OK;
}

Minimal test - lines (148, 148)

path: .spaces[4].metrics.halstead.difficulty
old: 3.5
new: 7.0

path: .spaces[4].metrics.halstead.time
old: 6.459304628947649
new: 18.491229175080157

path: .spaces[4].metrics.halstead.vocabulary
old: 10.0
new: 9.0

path: .spaces[4].metrics.halstead.n2
old: 3.0
new: 2.0

path: .spaces[4].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 21.651484454403228

path: .spaces[4].metrics.halstead.volume
old: 33.219280948873624
new: 47.548875021634686

path: .spaces[4].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.01600924813896547

path: .spaces[4].metrics.halstead.length
old: 10.0
new: 15.0

path: .spaces[4].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 1.4434322969602151

path: .spaces[4].metrics.halstead.N1
old: 7.0
new: 11.0

path: .spaces[4].metrics.halstead.effort
old: 116.26748332105768
new: 332.8421251514428

path: .spaces[4].metrics.halstead.level
old: 0.2857142857142857
new: 0.14285714285714285

path: .spaces[4].metrics.halstead.N2
old: 3.0
new: 4.0

path: .spaces[4].metrics.mi.mi_original
old: 134.75620253769355
new: 150.4588577247253

path: .spaces[4].metrics.mi.mi_sei
old: 118.81307299755096
new: 141.56903562407547

path: .spaces[4].metrics.mi.mi_visual_studio
old: 78.80479680566874
new: 87.98763609633059

path: .spaces[4].metrics.cognitive.sum
old: 0.0
new: 1.0

path: .spaces[4].metrics.cognitive.average
old: 0.0
new: 1.0

path: .spaces[4].metrics.cyclomatic.average
old: 1.0
new: 2.0

path: .spaces[4].metrics.cyclomatic.sum
old: 1.0
new: 2.0

path: .spaces[4].metrics.loc.sloc
old: 3.0
new: 1.0

path: .spaces[4].metrics.loc.ploc
old: 3.0
new: 1.0

path: .spaces[4].metrics.nargs.sum
old: 0.0
new: 1.0

path: .spaces[4].metrics.nargs.average
old: 0.0
new: 1.0

Code

inline bool IsEOL(char16_t aChar) { return (aChar == '\r') || (aChar == '\n'); }

Minimal test - lines (51, 141)

path: .spaces[2].metrics.mi.mi_sei
old: 118.81307299755096
new: 41.278105149291555

path: .spaces[2].metrics.mi.mi_original
old: 134.75620253769355
new: 56.38788634723731

path: .spaces[2].metrics.mi.mi_visual_studio
old: 78.80479680566874
new: 32.975372132887316

path: .spaces[2].metrics.nexits.average
old: 1.0
new: 0.125

path: .spaces[2].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.3273369772919532

path: .spaces[2].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 1.497436964904833

path: .spaces[2].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 431.26184589259185

path: .spaces[2].metrics.halstead.volume
old: 33.219280948873624
new: 1810.1958390323275

path: .spaces[2].metrics.halstead.N2
old: 3.0
new: 122.0

path: .spaces[2].metrics.halstead.level
old: 0.2857142857142857
new: 0.058823529411764705

path: .spaces[2].metrics.halstead.effort
old: 116.26748332105768
new: 30773.329263549567

path: .spaces[2].metrics.halstead.difficulty
old: 3.5
new: 17.0

path: .spaces[2].metrics.halstead.N1
old: 7.0
new: 166.0

path: .spaces[2].metrics.halstead.time
old: 6.459304628947649
new: 1709.6294035305316

path: .spaces[2].metrics.halstead.length
old: 10.0
new: 288.0

path: .spaces[2].metrics.halstead.n1
old: 7.0
new: 17.0

path: .spaces[2].metrics.halstead.n2
old: 3.0
new: 61.0

path: .spaces[2].metrics.halstead.vocabulary
old: 10.0
new: 78.0

path: .spaces[2].metrics.loc.lloc
old: 1.0
new: 20.0

path: .spaces[2].metrics.loc.ploc
old: 3.0
new: 64.0

path: .spaces[2].metrics.loc.blank
old: 0.0
new: 5.0

path: .spaces[2].metrics.loc.cloc
old: 0.0
new: 22.0

path: .spaces[2].metrics.loc.sloc
old: 3.0
new: 91.0

path: .spaces[2].metrics.cognitive.average
old: 0.0
new: 0.25

path: .spaces[2].metrics.cognitive.sum
old: 0.0
new: 2.0

path: .spaces[2].metrics.nom.functions
old: 1.0
new: 8.0

path: .spaces[2].metrics.nom.total
old: 1.0
new: 8.0

path: .spaces[2].metrics.cyclomatic.sum
old: 1.0
new: 11.0

path: .spaces[2].metrics.cyclomatic.average
old: 1.0
new: 1.2222222222222223

path: .spaces[2].metrics.nargs.sum
old: 0.0
new: 2.0

path: .spaces[2].metrics.nargs.average
old: 0.0
new: 0.25

Code

class MOZ_STACK_CLASS nsPropertiesParser {
 public:
  explicit nsPropertiesParser(nsIPersistentProperties* aProps)
      : mUnicodeValuesRead(0),
        mUnicodeValue(u'\0'),
        mHaveMultiLine(false),
        mMultiLineCanSkipN(false),
        mMinLength(0),
        mState(eParserState_AwaitingKey),
        mSpecialState(eParserSpecial_None),
        mProps(aProps) {}

  void FinishValueState(nsAString& aOldValue) {
    static const char trimThese[] = " \t";
    mKey.Trim(trimThese, false, true);

    // This is really ugly hack but it should be fast
    char16_t backup_char;
    uint32_t minLength = mMinLength;
    if (minLength) {
      backup_char = mValue[minLength - 1];
      mValue.SetCharAt('x', minLength - 1);
    }
    mValue.Trim(trimThese, false, true);
    if (minLength) {
      mValue.SetCharAt(backup_char, minLength - 1);
    }

    mProps->SetStringProperty(NS_ConvertUTF16toUTF8(mKey), mValue, aOldValue);
    mSpecialState = eParserSpecial_None;
    WaitForKey();
  }

  EParserState GetState() { return mState; }

  static nsresult SegmentWriter(nsIUnicharInputStream* aStream, void* aClosure,
                                const char16_t* aFromSegment,
                                uint32_t aToOffset, uint32_t aCount,
                                uint32_t* aWriteCount);

  nsresult ParseBuffer(const char16_t* aBuffer, uint32_t aBufferLength);

 private:
  bool ParseValueCharacter(
      char16_t aChar,                // character that is just being parsed
      const char16_t* aCur,          // pointer to character aChar in the buffer
      const char16_t*& aTokenStart,  // string copying is done in blocks as big
                                     // as possible, aTokenStart points to the
                                     // beginning of this block
      nsAString& aOldValue);  // when duplicate property is found, new value
                              // is stored into hashtable and the old one is
                              // placed in this variable

  void WaitForKey() { mState = eParserState_AwaitingKey; }

  void EnterKeyState() {
    mKey.Truncate();
    mState = eParserState_Key;
  }

  void WaitForValue() { mState = eParserState_AwaitingValue; }

  void EnterValueState() {
    mValue.Truncate();
    mMinLength = 0;
    mState = eParserState_Value;
    mSpecialState = eParserSpecial_None;
  }

  void EnterCommentState() { mState = eParserState_Comment; }

  nsAutoString mKey;
  nsAutoString mValue;

  uint32_t mUnicodeValuesRead;  // should be 4!
  char16_t mUnicodeValue;       // currently parsed unicode value
  bool mHaveMultiLine;          // is TRUE when last processed characters form
                                // any of following sequences:
                                //  - "\\\r"
                                //  - "\\\n"
                                //  - "\\\r\n"
                                //  - any sequence above followed by any
                                //    combination of ' ' and '\t'
  bool mMultiLineCanSkipN;      // TRUE if "\\\r" was detected
  uint32_t mMinLength;          // limit right trimming at the end to not trim
                                // escaped whitespaces
  EParserState mState;
  // if we see a '\' then we enter this special state
  EParserSpecial mSpecialState;
  nsCOMPtr mProps;
};

Minimal test - lines (150, 295)

path: .spaces[5].metrics.cyclomatic.average
old: 1.0
new: 28.0

path: .spaces[5].metrics.cyclomatic.sum
old: 1.0
new: 28.0

path: .spaces[5].metrics.halstead.effort
old: 116.26748332105768
new: 152724.84539224705

path: .spaces[5].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.952398146166948

path: .spaces[5].metrics.halstead.n1
old: 7.0
new: 29.0

path: .spaces[5].metrics.halstead.difficulty
old: 3.5
new: 69.15384615384616

path: .spaces[5].metrics.halstead.length
old: 10.0
new: 382.0

path: .spaces[5].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 263.09288153036795

path: .spaces[5].metrics.halstead.N2
old: 3.0
new: 124.0

path: .spaces[5].metrics.halstead.n2
old: 3.0
new: 26.0

path: .spaces[5].metrics.halstead.vocabulary
old: 10.0
new: 55.0

path: .spaces[5].metrics.halstead.time
old: 6.459304628947649
new: 8484.713632902614

path: .spaces[5].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 0.6887248207601255

path: .spaces[5].metrics.halstead.volume
old: 33.219280948873624
new: 2208.47941056642

path: .spaces[5].metrics.halstead.level
old: 0.2857142857142857
new: 0.014460511679644048

path: .spaces[5].metrics.halstead.N1
old: 7.0
new: 258.0

path: .spaces[5].metrics.mi.mi_original
old: 152.55372161411694
new: 43.78526328579083

path: .spaces[5].metrics.mi.mi_sei
old: 144.4894655092337
new: 23.90468610619508

path: .spaces[5].metrics.mi.mi_visual_studio
old: 89.21270269831399
new: 25.60541712619347

path: .spaces[5].metrics.loc.sloc
old: 1.0
new: 146.0

path: .spaces[5].metrics.loc.cloc
old: 0.0
new: 33.0

path: .spaces[5].metrics.loc.blank
old: 0.0
new: 13.0

path: .spaces[5].metrics.loc.lloc
old: 1.0
new: 84.0

path: .spaces[5].metrics.loc.ploc
old: 1.0
new: 100.0

path: .spaces[5].metrics.nargs.sum
old: 0.0
new: 4.0

path: .spaces[5].metrics.nargs.average
old: 0.0
new: 4.0

path: .spaces[5].metrics.cognitive.sum
old: 0.0
new: 29.0

path: .spaces[5].metrics.cognitive.average
old: 0.0
new: 29.0

path: .spaces[5].metrics.nexits.sum
old: 1.0
new: 2.0

path: .spaces[5].metrics.nexits.average
old: 1.0
new: 2.0

Code

bool nsPropertiesParser::ParseValueCharacter(char16_t aChar,
                                             const char16_t* aCur,
                                             const char16_t*& aTokenStart,
                                             nsAString& aOldValue) {
  switch (mSpecialState) {
    // the normal state - look for special characters
    case eParserSpecial_None:
      switch (aChar) {
        case '\\':
          if (mHaveMultiLine) {
            // there is nothing to append to mValue yet
            mHaveMultiLine = false;
          } else {
            mValue += Substring(aTokenStart, aCur);
          }

          mSpecialState = eParserSpecial_Escaped;
          break;

        case '\n':
          // if we detected multiline and got only "\\\r" ignore next "\n" if
          // any
          if (mHaveMultiLine && mMultiLineCanSkipN) {
            // but don't allow another '\n' to be skipped
            mMultiLineCanSkipN = false;
            // Now there is nothing to append to the mValue since we are
            // skipping whitespaces at the beginning of the new line of the
            // multiline property. Set aTokenStart properly to ensure that
            // nothing is appended if we find regular line-end or the end of the
            // buffer.
            aTokenStart = aCur + 1;
            break;
          }
          [[fallthrough]];

        case '\r':
          // we're done! We have a key and value
          mValue += Substring(aTokenStart, aCur);
          FinishValueState(aOldValue);
          mHaveMultiLine = false;
          break;

        default:
          // there is nothing to do with normal characters,
          // but handle multilines correctly
          if (mHaveMultiLine) {
            if (aChar == ' ' || aChar == '\t') {
              // don't allow another '\n' to be skipped
              mMultiLineCanSkipN = false;
              // Now there is nothing to append to the mValue since we are
              // skipping whitespaces at the beginning of the new line of the
              // multiline property. Set aTokenStart properly to ensure that
              // nothing is appended if we find regular line-end or the end of
              // the buffer.
              aTokenStart = aCur + 1;
              break;
            }
            mHaveMultiLine = false;
            aTokenStart = aCur;
          }
          break;  // from switch on (aChar)
      }
      break;  // from switch on (mSpecialState)

    // saw a \ character, so parse the character after that
    case eParserSpecial_Escaped:
      // probably want to start parsing at the next token
      // other characters, like 'u' might override this
      aTokenStart = aCur + 1;
      mSpecialState = eParserSpecial_None;

      switch (aChar) {
        // the easy characters - \t, \n, and so forth
        case 't':
          mValue += char16_t('\t');
          mMinLength = mValue.Length();
          break;
        case 'n':
          mValue += char16_t('\n');
          mMinLength = mValue.Length();
          break;
        case 'r':
          mValue += char16_t('\r');
          mMinLength = mValue.Length();
          break;
        case '\\':
          mValue += char16_t('\\');
          break;

        // switch to unicode mode!
        case 'u':
        case 'U':
          mSpecialState = eParserSpecial_Unicode;
          mUnicodeValuesRead = 0;
          mUnicodeValue = 0;
          break;

        // a \ immediately followed by a newline means we're going multiline
        case '\r':
        case '\n':
          mHaveMultiLine = true;
          mMultiLineCanSkipN = (aChar == '\r');
          mSpecialState = eParserSpecial_None;
          break;

        default:
          // don't recognize the character, so just append it
          mValue += aChar;
          break;
      }
      break;

    // we're in the middle of parsing a 4-character unicode value
    // like \u5f39
    case eParserSpecial_Unicode:
      if ('0' <= aChar && aChar <= '9') {
        mUnicodeValue = (mUnicodeValue << 4) | (aChar - '0');
      } else if ('a' <= aChar && aChar <= 'f') {
        mUnicodeValue = (mUnicodeValue << 4) | (aChar - 'a' + 0x0a);
      } else if ('A' <= aChar && aChar <= 'F') {
        mUnicodeValue = (mUnicodeValue << 4) | (aChar - 'A' + 0x0a);
      } else {
        // non-hex character. Append what we have, and move on.
        mValue += mUnicodeValue;
        mMinLength = mValue.Length();
        mSpecialState = eParserSpecial_None;

        // leave aTokenStart at this unknown character, so it gets appended
        aTokenStart = aCur;

        // ensure parsing this non-hex character again
        return false;
      }

      if (++mUnicodeValuesRead >= 4) {
        aTokenStart = aCur + 1;
        mSpecialState = eParserSpecial_None;
        mValue += mUnicodeValue;
        mMinLength = mValue.Length();
      }

      break;
  }

  return true;
}

Minimal test - lines (405, 408)

path: .spaces[8].metrics.mi.mi_original
old: 152.55372161411694
new: 125.15235316202264

path: .spaces[8].metrics.mi.mi_sei
old: 144.4894655092337
new: 104.95764712982594

path: .spaces[8].metrics.mi.mi_visual_studio
old: 89.21270269831399
new: 73.18851062106587

path: .spaces[8].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 43.65148445440323

path: .spaces[8].metrics.halstead.time
old: 6.459304628947649
new: 16.712809770103107

path: .spaces[8].metrics.halstead.effort
old: 116.26748332105768
new: 300.83057586185595

path: .spaces[8].metrics.halstead.volume
old: 33.219280948873624
new: 85.95159310338741

path: .spaces[8].metrics.halstead.N1
old: 7.0
new: 14.0

path: .spaces[8].metrics.halstead.N2
old: 3.0
new: 8.0

path: .spaces[8].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.014965574571529076

path: .spaces[8].metrics.halstead.vocabulary
old: 10.0
new: 15.0

path: .spaces[8].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 1.984158384291056

path: .spaces[8].metrics.halstead.length
old: 10.0
new: 22.0

path: .spaces[8].metrics.halstead.n2
old: 3.0
new: 8.0

path: .spaces[8].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[8].metrics.nexits.average
old: 1.0
new: 0.0

path: .spaces[8].metrics.loc.ploc
old: 1.0
new: 4.0

path: .spaces[8].metrics.loc.lloc
old: 1.0
new: 0.0

path: .spaces[8].metrics.loc.sloc
old: 1.0
new: 4.0

Code

nsPersistentProperties::nsPersistentProperties()
    : mIn(nullptr),
      mTable(&property_HashTableOps, sizeof(PropertyTableEntry), 16),
      mArena() {}

Minimal test - lines (26, 26)

path: .spaces[1].metrics.nargs.average
old: 0.0
new: null

path: .spaces[1].metrics.nexits.average
old: 1.0
new: null

path: .spaces[1].metrics.nexits.sum
old: 1.0
new: 0.0

path: .spaces[1].metrics.loc.sloc
old: 3.0
new: 1.0

path: .spaces[1].metrics.loc.ploc
old: 3.0
new: 1.0

path: .spaces[1].metrics.loc.lloc
old: 1.0
new: 0.0

path: .spaces[1].metrics.cognitive.average
old: 0.0
new: null

path: .spaces[1].metrics.nom.total
old: 1.0
new: 0.0

path: .spaces[1].metrics.nom.functions
old: 1.0
new: 0.0

path: .spaces[1].metrics.mi.mi_visual_studio
old: 78.80479680566874
new: null

path: .spaces[1].metrics.mi.mi_sei
old: 118.81307299755096
new: null

path: .spaces[1].metrics.mi.mi_original
old: 134.75620253769355
new: null

path: .spaces[1].metrics.halstead.N2
old: 3.0
new: 1.0

path: .spaces[1].metrics.halstead.difficulty
old: 3.5
new: 0.0

path: .spaces[1].metrics.halstead.length
old: 10.0
new: 1.0

path: .spaces[1].metrics.halstead.n2
old: 3.0
new: 1.0

path: .spaces[1].metrics.halstead.volume
old: 33.219280948873624
new: 0.0

path: .spaces[1].metrics.halstead.N1
old: 7.0
new: 0.0

path: .spaces[1].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: null

path: .spaces[1].metrics.halstead.effort
old: 116.26748332105768
new: 0.0

path: .spaces[1].metrics.halstead.level
old: 0.2857142857142857
new: null

path: .spaces[1].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: null

path: .spaces[1].metrics.halstead.n1
old: 7.0
new: 0.0

path: .spaces[1].metrics.halstead.time
old: 6.459304628947649
new: 0.0

path: .spaces[1].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.0

path: .spaces[1].metrics.halstead.vocabulary
old: 10.0
new: 1.0

Code

static const struct PLDHashTableOps property_HashTableOps = {

Minimal test - lines (143, 146)

path: .spaces[3].metrics.cognitive.sum
old: 0.0
new: 1.0

path: .spaces[3].metrics.cognitive.average
old: 0.0
new: 1.0

path: .spaces[3].metrics.halstead.effort
old: 116.26748332105768
new: 765.5368878483184

path: .spaces[3].metrics.halstead.N2
old: 3.0
new: 6.0

path: .spaces[3].metrics.halstead.vocabulary
old: 10.0
new: 9.0

path: .spaces[3].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 0.9413688893218796

path: .spaces[3].metrics.halstead.time
old: 6.459304628947649
new: 42.52982710268436

path: .spaces[3].metrics.halstead.n2
old: 3.0
new: 2.0

path: .spaces[3].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.027894772692056917

path: .spaces[3].metrics.halstead.difficulty
old: 3.5
new: 10.5

path: .spaces[3].metrics.halstead.length
old: 10.0
new: 23.0

path: .spaces[3].metrics.halstead.N1
old: 7.0
new: 17.0

path: .spaces[3].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 21.651484454403228

path: .spaces[3].metrics.halstead.level
old: 0.2857142857142857
new: 0.09523809523809525

path: .spaces[3].metrics.halstead.volume
old: 33.219280948873624
new: 72.90827503317318

path: .spaces[3].metrics.mi.mi_original
old: 134.75620253769355
new: 125.318180197483

path: .spaces[3].metrics.mi.mi_sei
old: 118.81307299755096
new: 105.50234454974331

path: .spaces[3].metrics.mi.mi_visual_studio
old: 78.80479680566874
new: 73.28548549560409

path: .spaces[3].metrics.nargs.average
old: 0.0
new: 1.0

path: .spaces[3].metrics.nargs.sum
old: 0.0
new: 1.0

path: .spaces[3].metrics.loc.ploc
old: 3.0
new: 4.0

path: .spaces[3].metrics.loc.sloc
old: 3.0
new: 4.0

path: .spaces[3].metrics.cyclomatic.average
old: 1.0
new: 4.0

path: .spaces[3].metrics.cyclomatic.sum
old: 1.0
new: 4.0

Code

inline bool IsWhiteSpace(char16_t aChar) {
  return (aChar == ' ') || (aChar == '\t') || (aChar == '\r') ||
         (aChar == '\n');
}

Minimal test - lines (309, 403)

path: .spaces[7].metrics.cyclomatic.average
old: 1.0
new: 25.0

path: .spaces[7].metrics.cyclomatic.sum
old: 1.0
new: 25.0

path: .spaces[7].metrics.loc.lloc
old: 1.0
new: 41.0

path: .spaces[7].metrics.loc.cloc
old: 0.0
new: 17.0

path: .spaces[7].metrics.loc.blank
old: 0.0
new: 15.0

path: .spaces[7].metrics.loc.ploc
old: 3.0
new: 63.0

path: .spaces[7].metrics.loc.sloc
old: 3.0
new: 95.0

path: .spaces[7].metrics.mi.mi_original
old: 134.75620253769355
new: 53.63709939864481

path: .spaces[7].metrics.mi.mi_visual_studio
old: 78.80479680566874
new: 31.366724794529127

path: .spaces[7].metrics.mi.mi_sei
old: 118.81307299755096
new: 34.69815985933164

path: .spaces[7].metrics.cognitive.sum
old: 0.0
new: 32.0

path: .spaces[7].metrics.cognitive.average
old: 0.0
new: 32.0

path: .spaces[7].metrics.nargs.sum
old: 0.0
new: 2.0

path: .spaces[7].metrics.nargs.average
old: 0.0
new: 2.0

path: .spaces[7].metrics.halstead.estimated_program_length
old: 24.406371956566694
new: 276.0964047443681

path: .spaces[7].metrics.halstead.length
old: 10.0
new: 248.0

path: .spaces[7].metrics.halstead.N2
old: 3.0
new: 87.0

path: .spaces[7].metrics.halstead.n2
old: 3.0
new: 32.0

path: .spaces[7].metrics.halstead.bugs
old: 0.007940556250510787
new: 0.44732370737

path: .spaces[7].metrics.halstead.N1
old: 7.0
new: 161.0

path: .spaces[7].metrics.halstead.volume
old: 33.219280948873624
new: 1446.5567235128558

path: .spaces[7].metrics.halstead.vocabulary
old: 10.0
new: 57.0

path: .spaces[7].metrics.halstead.level
old: 0.2857142857142857
new: 0.02942528735632184

path: .spaces[7].metrics.halstead.n1
old: 7.0
new: 25.0

path: .spaces[7].metrics.halstead.time
old: 6.459304628947649
new: 2731.129230590678

path: .spaces[7].metrics.halstead.effort
old: 116.26748332105768
new: 49160.32615063221

path: .spaces[7].metrics.halstead.purity_ratio
old: 2.4406371956566693
new: 1.1132919546143876

path: .spaces[7].metrics.halstead.difficulty
old: 3.5
new: 33.984375

Code

nsresult nsPropertiesParser::ParseBuffer(const char16_t* aBuffer,
                                         uint32_t aBufferLength) {
  const char16_t* cur = aBuffer;
  const char16_t* end = aBuffer + aBufferLength;

  // points to the start/end of the current key or value
  const char16_t* tokenStart = nullptr;

  // if we're in the middle of parsing a key or value, make sure
  // the current token points to the beginning of the current buffer
  if (mState == eParserState_Key || mState == eParserState_Value) {
    tokenStart = aBuffer;
  }

  nsAutoString oldValue;

  while (cur != end) {
    char16_t c = *cur;

    switch (mState) {
      case eParserState_AwaitingKey:
        if (c == '#' || c == '!') {
          EnterCommentState();
        }

        else if (!IsWhiteSpace(c)) {
          // not a comment, not whitespace, we must have found a key!
          EnterKeyState();
          tokenStart = cur;
        }
        break;

      case eParserState_Key:
        if (c == '=' || c == ':') {
          mKey += Substring(tokenStart, cur);
          WaitForValue();
        }
        break;

      case eParserState_AwaitingValue:
        if (IsEOL(c)) {
          // no value at all! mimic the normal value-ending
          EnterValueState();
          FinishValueState(oldValue);
        }

        // ignore white space leading up to the value
        else if (!IsWhiteSpace(c)) {
          tokenStart = cur;
          EnterValueState();

          // make sure to handle this first character
          if (ParseValueCharacter(c, cur, tokenStart, oldValue)) {
            cur++;
          }
          // If the character isn't consumed, don't do cur++ and parse
          // the character again. This can happen f.e. for char 'X' in sequence
          // "\u00X". This character can be control character and must be
          // processed again.
          continue;
        }
        break;

      case eParserState_Value:
        if (ParseValueCharacter(c, cur, tokenStart, oldValue)) {
          cur++;
        }
        // See few lines above for reason of doing this
        continue;

      case eParserState_Comment:
        // stay in this state till we hit EOL
        if (c == '\r' || c == '\n') {
          WaitForKey();
        }
        break;
    }

    // finally, advance to the next character
    cur++;
  }

  // if we're still parsing the value and are in eParserSpecial_None, then
  // append whatever we have..
  if (mState == eParserState_Value && tokenStart &&
      mSpecialState == eParserSpecial_None) {
    mValue += Substring(tokenStart, cur);
  }
  // if we're still parsing the key, then append whatever we have..
  else if (mState == eParserState_Key && tokenStart) {
    mKey += Substring(tokenStart, cur);
  }

  return NS_OK;
}

Minimal test - lines (20, 24)

path: .spaces[0].metrics.cyclomatic.average
old: 2.0
new: 1.0

path: .spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 1.0

path: .spaces[0].metrics.halstead.effort
old: 2957.3008129651457
new: 95.09775004326936

path: .spaces[0].metrics.halstead.N1
old: 28.0
new: 8.0

path: .spaces[0].metrics.halstead.difficulty
old: 15.0
new: 2.5

path: .spaces[0].metrics.halstead.bugs
old: 0.06867664651704698
new: 0.006944786620971931

path: .spaces[0].metrics.halstead.length
old: 43.0
new: 12.0

path: .spaces[0].metrics.halstead.level
old: 0.06666666666666667
new: 0.4

path: .spaces[0].metrics.halstead.n2
old: 8.0
new: 4.0

path: .spaces[0].metrics.halstead.time
old: 164.29448960917478
new: 5.2832083357371875

path: .spaces[0].metrics.halstead.n1
old: 16.0
new: 5.0

path: .spaces[0].metrics.halstead.N2
old: 15.0
new: 4.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 2.046511627906977
new: 1.6341367062030674

path: .spaces[0].metrics.halstead.vocabulary
old: 24.0
new: 9.0

path: .spaces[0].metrics.halstead.volume
old: 197.1533875310097
new: 38.039100017307746

path: .spaces[0].metrics.halstead.estimated_program_length
old: 88.0
new: 19.60964047443681

path: .spaces[0].metrics.nexits.average
old: 0.0
new: null

path: .spaces[0].metrics.nom.functions
old: 1.0
new: 0.0

path: .spaces[0].metrics.nom.total
old: 1.0
new: 0.0

path: .spaces[0].metrics.nargs.average
old: 2.0
new: null

path: .spaces[0].metrics.nargs.sum
old: 2.0
new: 0.0

path: .spaces[0].metrics.cognitive.average
old: 1.0
new: null

path: .spaces[0].metrics.cognitive.sum
old: 1.0
new: 0.0

path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 1.0

path: .spaces[0].metrics.loc.lloc
old: 2.0
new: 0.0

path: .spaces[0].metrics.loc.ploc
old: 5.0
new: 4.0

path: .spaces[0].metrics.mi.mi_original
old: 116.99039919662236
new: 125.7763100101268

path: .spaces[0].metrics.mi.mi_visual_studio
old: 68.41543812667973
new: 73.55339766674082

path: .spaces[0].metrics.mi.mi_sei
old: 93.2842564793834
new: 137.79331711316482

Code

struct PropertyTableEntry : public PLDHashEntryHdr {
  // both of these are arena-allocated
  const char* mKey;
  const char16_t* mValue;
};