Global Metrics

path: .metrics.cognitive.average
old: 3.0
new: 2.0

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

path: .metrics.halstead.level
old: 0.02844444444444445
new: 0.06971153846153846

path: .metrics.halstead.N2
old: 90.0
new: 52.0

path: .metrics.halstead.effort
old: 44703.63362418446
new: 11423.054440365722

path: .metrics.halstead.vocabulary
old: 57.0
new: 45.0

path: .metrics.halstead.difficulty
old: 35.15625
new: 14.344827586206897

path: .metrics.halstead.n1
old: 25.0
new: 16.0

path: .metrics.halstead.time
old: 2483.5352013435813
new: 634.6141355758734

path: .metrics.halstead.purity_ratio
old: 1.2664972694695784
new: 1.4129755093703418

path: .metrics.halstead.estimated_program_length
old: 276.0964047443681
new: 204.88144885869957

path: .metrics.halstead.length
old: 218.0
new: 145.0

path: .metrics.halstead.n2
old: 32.0
new: 29.0

path: .metrics.halstead.bugs
old: 0.4198627010697
new: 0.16907013898151096

path: .metrics.halstead.volume
old: 1271.5700230879136
new: 796.3186989678028

path: .metrics.halstead.N1
old: 128.0
new: 93.0

path: .metrics.mi.mi_sei
old: 49.59372193971052
new: 53.15358069153682

path: .metrics.mi.mi_original
old: 59.65028389043471
new: 69.95385445620445

path: .metrics.mi.mi_visual_studio
old: 34.88320695347059
new: 40.908686816493834

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

path: .metrics.loc.sloc
old: 81.0
new: 52.0

path: .metrics.loc.ploc
old: 47.0
new: 38.0

path: .metrics.loc.cloc
old: 25.0
new: 7.0

path: .metrics.loc.blank
old: 9.0
new: 7.0

path: .metrics.cyclomatic.average
old: 2.1666666666666665
new: 1.6666666666666667

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

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

path: .metrics.nom.functions
old: 4.0
new: 2.0

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

path: .metrics.nexits.average
old: 0.75
new: 3.0

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

Spaces Data

Minimal test - lines (13, 49)

path: .spaces[0].spaces[0].metrics.mi.mi_original
old: null
new: 76.2756281558436

path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: null
new: 35.156177364349105

path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: null
new: 44.605630500493334

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

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

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

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

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

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

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

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

path: .spaces[0].spaces[0].metrics.halstead.effort
old: 0.0
new: 11200.28391877438

path: .spaces[0].spaces[0].metrics.halstead.level
old: null
new: 0.06648936170212766

path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.2956575880889791

path: .spaces[0].spaces[0].metrics.halstead.volume
old: 0.0
new: 744.6997286419137

path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 41.0

path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 0.0
new: 15.04

path: .spaces[0].spaces[0].metrics.halstead.time
old: 0.0
new: 622.2379954874656

path: .spaces[0].spaces[0].metrics.halstead.n2
old: 1.0
new: 25.0

path: .spaces[0].spaces[0].metrics.halstead.N2
old: 1.0
new: 47.0

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

path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.166864813161624

path: .spaces[0].spaces[0].metrics.halstead.N1
old: 0.0
new: 92.0

path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: null
new: 180.0964047443681

path: .spaces[0].spaces[0].metrics.halstead.length
old: 1.0
new: 139.0

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

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

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

path: .spaces[0].spaces[0].metrics.loc.sloc
old: 1.0
new: 37.0

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

path: .spaces[0].spaces[0].metrics.loc.ploc
old: 1.0
new: 31.0

Code

namespace widget {

class Base64UtilsSupport final
    : public java::Base64Utils::Natives {
 public:
  static jni::ByteArray::LocalRef Decode(jni::String::Param data) {
    if (!data) {
      return nullptr;
    }

    FallibleTArray bytes;
    if (NS_FAILED(Base64URLDecode(
            data->ToCString(), Base64URLDecodePaddingPolicy::Ignore, bytes))) {
      return nullptr;
    }

    return jni::ByteArray::New((const signed char*)bytes.Elements(),
                               bytes.Length());
  }

  static jni::String::LocalRef Encode(jni::ByteArray::Param data) {
    if (!data) {
      return nullptr;
    }

    nsTArray bytes = data->GetElements();
    nsCString result;
    if (NS_FAILED(
            Base64URLEncode(data->Length(), (const uint8_t*)bytes.Elements(),
                            Base64URLEncodePaddingPolicy::Omit, result))) {
      return nullptr;
    }
    return jni::StringParam(result);
  }
};

}  // namespace widget

Minimal test - lines (12, 50)

path: .spaces[0].metrics.mi.mi_original
old: 64.93264146078616
new: 75.0848786490809

path: .spaces[0].metrics.mi.mi_visual_studio
old: 37.97230494782816
new: 43.90928575969644

path: .spaces[0].metrics.mi.mi_sei
old: 52.209934225085505
new: 45.81675802000722

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

path: .spaces[0].metrics.loc.sloc
old: 60.0
new: 39.0

path: .spaces[0].metrics.loc.ploc
old: 42.0
new: 33.0

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

path: .spaces[0].metrics.nexits.average
old: 0.75
new: 3.0

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

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

path: .spaces[0].metrics.nom.functions
old: 4.0
new: 2.0

path: .spaces[0].metrics.halstead.bugs
old: 0.42445340060695314
new: 0.16715281858841932

path: .spaces[0].metrics.halstead.effort
old: 45438.80571751311
new: 11229.293636112816

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

path: .spaces[0].metrics.halstead.level
old: 0.026976744186046512
new: 0.06770833333333333

path: .spaces[0].metrics.halstead.N1
old: 127.0
new: 93.0

path: .spaces[0].metrics.halstead.purity_ratio
old: 1.2064687962585336
new: 1.3206484586643148

path: .spaces[0].metrics.halstead.n2
old: 29.0
new: 26.0

path: .spaces[0].metrics.halstead.difficulty
old: 37.06896551724138
new: 14.76923076923077

path: .spaces[0].metrics.halstead.volume
old: 1225.7910379608188
new: 760.3167566118052

path: .spaces[0].metrics.halstead.N2
old: 86.0
new: 48.0

path: .spaces[0].metrics.halstead.estimated_program_length
old: 256.9778536030677
new: 186.2114326716684

path: .spaces[0].metrics.halstead.vocabulary
old: 54.0
new: 42.0

path: .spaces[0].metrics.halstead.length
old: 213.0
new: 141.0

path: .spaces[0].metrics.halstead.time
old: 2524.378095417395
new: 623.849646450712

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

path: .spaces[0].metrics.cognitive.average
old: 3.0
new: 2.0

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

path: .spaces[0].metrics.cyclomatic.average
old: 2.4
new: 1.8

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

Code

namespace mozilla {
namespace widget {

class Base64UtilsSupport final
    : public java::Base64Utils::Natives {
 public:
  static jni::ByteArray::LocalRef Decode(jni::String::Param data) {
    if (!data) {
      return nullptr;
    }

    FallibleTArray bytes;
    if (NS_FAILED(Base64URLDecode(
            data->ToCString(), Base64URLDecodePaddingPolicy::Ignore, bytes))) {
      return nullptr;
    }

    return jni::ByteArray::New((const signed char*)bytes.Elements(),
                               bytes.Length());
  }

  static jni::String::LocalRef Encode(jni::ByteArray::Param data) {
    if (!data) {
      return nullptr;
    }

    nsTArray bytes = data->GetElements();
    nsCString result;
    if (NS_FAILED(
            Base64URLEncode(data->Length(), (const uint8_t*)bytes.Elements(),
                            Base64URLEncodePaddingPolicy::Omit, result))) {
      return nullptr;
    }
    return jni::StringParam(result);
  }
};

}  // namespace widget
}  // namespace mozilla