Global Metrics

path: .metrics.mi.mi_sei
old: 8.632046686325715
new: 51.83326121666552

path: .metrics.mi.mi_original
old: 29.93485083680004
new: 64.36227322400096

path: .metrics.mi.mi_visual_studio
old: 17.505760723274875
new: 37.638756271345585

path: .metrics.nargs.average
old: null
new: 1.0

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

path: .metrics.nom.closures
old: 0.0
new: 1.0

path: .metrics.nom.functions
old: 0.0
new: 1.0

path: .metrics.nom.total
old: 0.0
new: 2.0

path: .metrics.loc.cloc
old: 142.0
new: 15.0

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

path: .metrics.loc.lloc
old: 0.0
new: 15.0

path: .metrics.loc.sloc
old: 373.0
new: 66.0

path: .metrics.loc.ploc
old: 191.0
new: 40.0

path: .metrics.nexits.sum
old: 0.0
new: 3.0

path: .metrics.nexits.average
old: null
new: 1.5

path: .metrics.halstead.n1
old: 7.0
new: 19.0

path: .metrics.halstead.bugs
old: 0.35858282422416754
new: 0.23338418659309287

path: .metrics.halstead.difficulty
old: 6.8478260869565215
new: 16.682926829268293

path: .metrics.halstead.estimated_program_length
old: 1199.9291018308566
new: 300.37025494476956

path: .metrics.halstead.length
old: 697.0
new: 188.0

path: .metrics.halstead.N2
old: 315.0
new: 72.0

path: .metrics.halstead.time
old: 1960.16938618139
new: 1029.2396686592017

path: .metrics.halstead.vocabulary
old: 168.0
new: 60.0

path: .metrics.halstead.n2
old: 161.0
new: 41.0

path: .metrics.halstead.level
old: 0.14603174603174604
new: 0.059941520467836254

path: .metrics.halstead.purity_ratio
old: 1.7215625564287755
new: 1.5977141220466466

path: .metrics.halstead.effort
old: 35283.04895126502
new: 18526.314035865627

path: .metrics.halstead.N1
old: 382.0
new: 116.0

path: .metrics.halstead.volume
old: 5152.445243676796
new: 1110.4954319744015

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

path: .metrics.cognitive.average
old: null
new: 6.0

path: .metrics.cyclomatic.sum
old: 3.0
new: 10.0

path: .metrics.cyclomatic.average
old: 1.5
new: 3.3333333333333335

Spaces Data

Minimal test - lines (14, 66)

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

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

path: .spaces[0].metrics.loc.blank
old: 0.0
new: 8.0

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

path: .spaces[0].metrics.loc.sloc
old: 4.0
new: 53.0

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

path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 3.0

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

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

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

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

path: .spaces[0].metrics.halstead.time
old: 1.2477132986922683
new: 951.3075184484092

path: .spaces[0].metrics.halstead.level
old: 1.0
new: 0.05901116427432217

path: .spaces[0].metrics.halstead.n1
old: 2.0
new: 19.0

path: .spaces[0].metrics.halstead.N2
old: 5.0
new: 66.0

path: .spaces[0].metrics.halstead.bugs
old: 0.0026534054573181228
new: 0.2214493286919499

path: .spaces[0].metrics.halstead.length
old: 8.0
new: 174.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.7012050593046013
new: 1.57161147864195

path: .spaces[0].metrics.halstead.N1
old: 3.0
new: 108.0

path: .spaces[0].metrics.halstead.difficulty
old: 1.0
new: 16.945945945945947

path: .spaces[0].metrics.halstead.effort
old: 22.458839376460833
new: 17123.535332071366

path: .spaces[0].metrics.halstead.n2
old: 5.0
new: 37.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 13.60964047443681
new: 273.4603972836993

path: .spaces[0].metrics.halstead.volume
old: 22.458839376460833
new: 1010.4797564380232

path: .spaces[0].metrics.halstead.vocabulary
old: 7.0
new: 56.0

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

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

path: .spaces[0].metrics.mi.mi_original
old: 132.13127313109095
new: 68.63673238262082

path: .spaces[0].metrics.mi.mi_visual_studio
old: 77.26975036905904
new: 40.13843998983674

path: .spaces[0].metrics.mi.mi_sei
old: 149.9974938831342
new: 54.03273398172112

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

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

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

Code

namespace mozilla {

void NSPRLogModulesParser(
    const char* aLogModules,
    const std::function& aCallback) {
  if (!aLogModules) {
    return;
  }

  Tokenizer parser(aLogModules, kDelimiters, kAdditionalWordChars);
  nsAutoCString moduleName;

  Tokenizer::Token rustModSep =
      parser.AddCustomToken("::", Tokenizer::CASE_SENSITIVE);

  auto readModuleName = [&](nsAutoCString& moduleName) -> bool {
    moduleName.Truncate();
    nsDependentCSubstring sub;
    parser.Record();
    // If the name doesn't include at least one word, we've reached the end.
    if (!parser.ReadWord(sub)) {
      return false;
    }
    // We will exit this loop if when any of the condition fails
    while (parser.Check(rustModSep) && parser.ReadWord(sub)) {
    }
    // Claim will include characters of the last sucessfully read item
    parser.Claim(moduleName, Tokenizer::INCLUDE_LAST);
    return true;
  };

  // Format: LOG_MODULES="Foo:2,Bar, Baz:5,rust_crate::mod::file:5"
  while (readModuleName(moduleName)) {
    // Next should be :, default to Error if not provided.
    LogLevel logLevel = LogLevel::Error;
    int32_t levelValue = 0;
    if (parser.CheckChar(':')) {
      // NB: If a level isn't provided after the ':' we assume the default
      //     Error level is desired. This differs from NSPR which will stop
      //     processing the log module string in this case.
      if (parser.ReadSignedInteger(&levelValue)) {
        logLevel = ToLogLevel(levelValue);
      }
    }

    aCallback(moduleName.get(), logLevel, levelValue);

    // Skip ahead to the next token.
    parser.SkipWhites();
  }
}

}  // namespace mozilla