Global Metrics
path: .metrics.cyclomatic.sum
old: 175.0
new: 23.0
path: .metrics.cyclomatic.average
old: 4.861111111111111
new: 1.0952380952380951
path: .metrics.nom.functions
old: 32.0
new: 12.0
path: .metrics.nom.total
old: 32.0
new: 12.0
path: .metrics.mi.mi_original
old: -33.72358278373146
new: 33.61018920866083
path: .metrics.mi.mi_sei
old: -88.08375322147265
new: 2.4313822873761666
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 19.655081408573583
path: .metrics.loc.blank
old: 118.0
new: 36.0
path: .metrics.loc.lloc
old: 309.0
new: 3.0
path: .metrics.loc.cloc
old: 50.0
new: 31.0
path: .metrics.loc.sloc
old: 840.0
new: 223.0
path: .metrics.loc.ploc
old: 672.0
new: 156.0
path: .metrics.nexits.sum
old: 29.0
new: 1.0
path: .metrics.nexits.average
old: 0.90625
new: 0.08333333333333333
path: .metrics.nargs.average
old: 4.625
new: 0.16666666666666666
path: .metrics.nargs.sum
old: 148.0
new: 2.0
path: .metrics.halstead.n1
old: 38.0
new: 16.0
path: .metrics.halstead.n2
old: 330.0
new: 138.0
path: .metrics.halstead.N2
old: 2262.0
new: 300.0
path: .metrics.halstead.level
old: 0.007678347061287169
new: 0.0575
path: .metrics.halstead.vocabulary
old: 368.0
new: 154.0
path: .metrics.halstead.effort
old: 5508205.618783908
new: 90613.6686900564
path: .metrics.halstead.N1
old: 2700.0
new: 417.0
path: .metrics.halstead.purity_ratio
old: 0.5965956421225264
new: 1.4574286960047242
path: .metrics.halstead.estimated_program_length
old: 2960.3075762119756
new: 1044.9763750353873
path: .metrics.halstead.difficulty
old: 130.23636363636365
new: 17.391304347826086
path: .metrics.halstead.volume
old: 42293.91442595489
new: 5210.285949678244
path: .metrics.halstead.length
old: 4962.0
new: 717.0
path: .metrics.halstead.bugs
old: 10.396460500489075
new: 0.6724725396862772
path: .metrics.halstead.time
old: 306011.42326577264
new: 5034.092705003134
path: .metrics.cognitive.average
old: 6.75
new: 0.0
path: .metrics.cognitive.sum
old: 216.0
new: 0.0
Spaces Data
Minimal test - lines (190, 198)
path: .spaces[2].metrics.halstead.N2
old: 28.0
new: 5.0
path: .spaces[2].metrics.halstead.effort
old: 2702.439475283252
new: 348.802449963173
path: .spaces[2].metrics.halstead.level
old: 0.0974025974025974
new: 0.17142857142857143
path: .spaces[2].metrics.halstead.n1
old: 11.0
new: 7.0
path: .spaces[2].metrics.halstead.purity_ratio
old: 1.7260197631988936
new: 1.3559095531425942
path: .spaces[2].metrics.halstead.volume
old: 263.22462421590114
new: 59.79470570797252
path: .spaces[2].metrics.halstead.difficulty
old: 10.266666666666667
new: 5.833333333333333
path: .spaces[2].metrics.halstead.estimated_program_length
old: 96.65710673913804
new: 24.406371956566694
path: .spaces[2].metrics.halstead.N1
old: 28.0
new: 13.0
path: .spaces[2].metrics.halstead.time
old: 150.1355264046251
new: 19.377913886842943
path: .spaces[2].metrics.halstead.n2
old: 15.0
new: 3.0
path: .spaces[2].metrics.halstead.length
old: 56.0
new: 18.0
path: .spaces[2].metrics.halstead.vocabulary
old: 26.0
new: 10.0
path: .spaces[2].metrics.halstead.bugs
old: 0.0646719658792217
new: 0.016517022602721167
path: .spaces[2].metrics.mi.mi_sei
old: 77.37843161312729
new: 88.26709657178249
path: .spaces[2].metrics.mi.mi_original
old: 105.96532153609662
new: 113.44219280377918
path: .spaces[2].metrics.mi.mi_visual_studio
old: 61.96802429011498
new: 66.34046362794105
path: .spaces[2].metrics.nargs.average
old: 4.0
new: 0.0
path: .spaces[2].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[2].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[2].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[2].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[2].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[2].metrics.cyclomatic.average
old: 2.0
new: 1.0
path: .spaces[2].metrics.cyclomatic.sum
old: 2.0
new: 3.0
path: .spaces[2].metrics.loc.ploc
old: 9.0
new: 7.0
path: .spaces[2].metrics.loc.lloc
old: 3.0
new: 0.0
path: .spaces[2].metrics.loc.blank
old: 0.0
new: 2.0
path: .spaces[2].metrics.nom.total
old: 1.0
new: 2.0
path: .spaces[2].metrics.nom.functions
old: 1.0
new: 2.0
Code
class nsVariant final : public nsVariantBase {
public:
NS_DECL_ISUPPORTS
nsVariant() = default;
private:
~nsVariant() = default;
};
Minimal test - lines (176, 188)
path: .spaces[1].metrics.halstead.vocabulary
old: 27.0
new: 15.0
path: .spaces[1].metrics.halstead.N2
old: 27.0
new: 9.0
path: .spaces[1].metrics.halstead.n2
old: 15.0
new: 7.0
path: .spaces[1].metrics.halstead.effort
old: 2875.7559613084654
new: 482.22192494368
path: .spaces[1].metrics.halstead.volume
old: 266.2737001211542
new: 93.76537429460444
path: .spaces[1].metrics.halstead.bugs
old: 0.06740830876865232
new: 0.02049793194218302
path: .spaces[1].metrics.halstead.difficulty
old: 10.8
new: 5.142857142857143
path: .spaces[1].metrics.halstead.N1
old: 29.0
new: 15.0
path: .spaces[1].metrics.halstead.length
old: 56.0
new: 24.0
path: .spaces[1].metrics.halstead.purity_ratio
old: 1.8146948025496723
new: 1.8188118522668013
path: .spaces[1].metrics.halstead.estimated_program_length
old: 101.62290894278166
new: 43.65148445440323
path: .spaces[1].metrics.halstead.time
old: 159.76422007269252
new: 26.790106941315557
path: .spaces[1].metrics.halstead.n1
old: 12.0
new: 8.0
path: .spaces[1].metrics.halstead.level
old: 0.0925925925925926
new: 0.1944444444444444
path: .spaces[1].metrics.loc.lloc
old: 3.0
new: 0.0
path: .spaces[1].metrics.loc.sloc
old: 8.0
new: 13.0
path: .spaces[1].metrics.loc.blank
old: 0.0
new: 3.0
path: .spaces[1].metrics.loc.ploc
old: 8.0
new: 10.0
path: .spaces[1].metrics.mi.mi_visual_studio
old: 63.04884119371826
new: 61.62320646838705
path: .spaces[1].metrics.mi.mi_original
old: 107.81351844125822
new: 105.37568306094188
path: .spaces[1].metrics.mi.mi_sei
old: 80.04481612279022
new: 76.52776310910416
path: .spaces[1].metrics.cyclomatic.average
old: 2.0
new: 1.0
path: .spaces[1].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[1].metrics.nargs.average
old: 4.0
new: 0.0
path: .spaces[1].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[1].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[1].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[1].metrics.nexits.average
old: 1.0
new: 0.0
Code
class nsVariantBase : public nsIWritableVariant {
public:
NS_DECL_NSIVARIANT
NS_DECL_NSIWRITABLEVARIANT
nsVariantBase();
protected:
~nsVariantBase() = default;
nsDiscriminatedUnion mData;
bool mWritable;
};
Minimal test - lines (29, 167)
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.1666666666666667
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 14.0
path: .spaces[0].metrics.nom.functions
old: 1.0
new: 7.0
path: .spaces[0].metrics.nom.total
old: 1.0
new: 7.0
path: .spaces[0].metrics.halstead.volume
old: 83.76180828526729
new: 4515.230992702516
path: .spaces[0].metrics.halstead.time
old: 19.195414398707086
new: 4252.7910960678455
path: .spaces[0].metrics.halstead.n1
old: 6.0
new: 15.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.7958988638330426
new: 1.375722492594324
path: .spaces[0].metrics.halstead.level
old: 0.24242424242424243
new: 0.058983890954151186
path: .spaces[0].metrics.halstead.difficulty
old: 4.125
new: 16.95378151260504
path: .spaces[0].metrics.halstead.N1
old: 11.0
new: 370.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 39.50977500432694
new: 879.086672767773
path: .spaces[0].metrics.halstead.length
old: 22.0
new: 639.0
path: .spaces[0].metrics.halstead.n2
old: 8.0
new: 119.0
path: .spaces[0].metrics.halstead.bugs
old: 0.016413155228072563
new: 0.6009566085428768
path: .spaces[0].metrics.halstead.vocabulary
old: 14.0
new: 134.0
path: .spaces[0].metrics.halstead.effort
old: 345.5174591767276
new: 76550.23972922123
path: .spaces[0].metrics.halstead.N2
old: 11.0
new: 269.0
path: .spaces[0].metrics.nexits.average
old: 1.0
new: 0.14285714285714285
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 15.0
path: .spaces[0].metrics.loc.lloc
old: 1.0
new: 3.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 5.0
path: .spaces[0].metrics.loc.sloc
old: 3.0
new: 139.0
path: .spaces[0].metrics.loc.ploc
old: 3.0
new: 119.0
path: .spaces[0].metrics.nargs.average
old: 2.0
new: 0.2857142857142857
path: .spaces[0].metrics.mi.mi_original
old: 129.94699971644644
new: 44.082421829555344
path: .spaces[0].metrics.mi.mi_visual_studio
old: 75.99239749499792
new: 25.779194052371544
path: .spaces[0].metrics.mi.mi_sei
old: 111.8748599367085
new: 3.8027089732458546
Code
class nsDiscriminatedUnion {
public:
nsDiscriminatedUnion() : mType(nsIDataType::VTYPE_EMPTY) {
u.mInt8Value = '\0';
}
nsDiscriminatedUnion(const nsDiscriminatedUnion&) = delete;
nsDiscriminatedUnion(nsDiscriminatedUnion&&) = delete;
~nsDiscriminatedUnion() { Cleanup(); }
nsDiscriminatedUnion& operator=(const nsDiscriminatedUnion&) = delete;
nsDiscriminatedUnion& operator=(nsDiscriminatedUnion&&) = delete;
void Cleanup();
uint16_t GetType() const { return mType; }
[[nodiscard]] nsresult ConvertToInt8(uint8_t* aResult) const;
[[nodiscard]] nsresult ConvertToInt16(int16_t* aResult) const;
[[nodiscard]] nsresult ConvertToInt32(int32_t* aResult) const;
[[nodiscard]] nsresult ConvertToInt64(int64_t* aResult) const;
[[nodiscard]] nsresult ConvertToUint8(uint8_t* aResult) const;
[[nodiscard]] nsresult ConvertToUint16(uint16_t* aResult) const;
[[nodiscard]] nsresult ConvertToUint32(uint32_t* aResult) const;
[[nodiscard]] nsresult ConvertToUint64(uint64_t* aResult) const;
[[nodiscard]] nsresult ConvertToFloat(float* aResult) const;
[[nodiscard]] nsresult ConvertToDouble(double* aResult) const;
[[nodiscard]] nsresult ConvertToBool(bool* aResult) const;
[[nodiscard]] nsresult ConvertToChar(char* aResult) const;
[[nodiscard]] nsresult ConvertToWChar(char16_t* aResult) const;
[[nodiscard]] nsresult ConvertToID(nsID* aResult) const;
[[nodiscard]] nsresult ConvertToAString(nsAString& aResult) const;
[[nodiscard]] nsresult ConvertToAUTF8String(nsAUTF8String& aResult) const;
[[nodiscard]] nsresult ConvertToACString(nsACString& aResult) const;
[[nodiscard]] nsresult ConvertToString(char** aResult) const;
[[nodiscard]] nsresult ConvertToWString(char16_t** aResult) const;
[[nodiscard]] nsresult ConvertToStringWithSize(uint32_t* aSize,
char** aStr) const;
[[nodiscard]] nsresult ConvertToWStringWithSize(uint32_t* aSize,
char16_t** aStr) const;
[[nodiscard]] nsresult ConvertToISupports(nsISupports** aResult) const;
[[nodiscard]] nsresult ConvertToInterface(nsIID** aIID,
void** aInterface) const;
[[nodiscard]] nsresult ConvertToArray(uint16_t* aType, nsIID* aIID,
uint32_t* aCount, void** aPtr) const;
[[nodiscard]] nsresult SetFromVariant(nsIVariant* aValue);
void SetFromInt8(uint8_t aValue);
void SetFromInt16(int16_t aValue);
void SetFromInt32(int32_t aValue);
void SetFromInt64(int64_t aValue);
void SetFromUint8(uint8_t aValue);
void SetFromUint16(uint16_t aValue);
void SetFromUint32(uint32_t aValue);
void SetFromUint64(uint64_t aValue);
void SetFromFloat(float aValue);
void SetFromDouble(double aValue);
void SetFromBool(bool aValue);
void SetFromChar(char aValue);
void SetFromWChar(char16_t aValue);
void SetFromID(const nsID& aValue);
void SetFromAString(const nsAString& aValue);
void SetFromAUTF8String(const nsAUTF8String& aValue);
void SetFromACString(const nsACString& aValue);
[[nodiscard]] nsresult SetFromString(const char* aValue);
[[nodiscard]] nsresult SetFromWString(const char16_t* aValue);
void SetFromISupports(nsISupports* aValue);
void SetFromInterface(const nsIID& aIID, nsISupports* aValue);
[[nodiscard]] nsresult SetFromArray(uint16_t aType, const nsIID* aIID,
uint32_t aCount, void* aValue);
[[nodiscard]] nsresult SetFromStringWithSize(uint32_t aSize,
const char* aValue);
[[nodiscard]] nsresult SetFromWStringWithSize(uint32_t aSize,
const char16_t* aValue);
// Like SetFromWStringWithSize, but leaves the string uninitialized. It does
// does write the null-terminator.
void AllocateWStringWithSize(uint32_t aSize);
void SetToVoid();
void SetToEmpty();
void SetToEmptyArray();
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
private:
[[nodiscard]] nsresult ToManageableNumber(
nsDiscriminatedUnion* aOutData) const;
void FreeArray();
[[nodiscard]] bool String2ID(nsID* aPid) const;
[[nodiscard]] nsresult ToString(nsACString& aOutString) const;
public:
union {
int8_t mInt8Value;
int16_t mInt16Value;
int32_t mInt32Value;
int64_t mInt64Value;
uint8_t mUint8Value;
uint16_t mUint16Value;
uint32_t mUint32Value;
uint64_t mUint64Value;
float mFloatValue;
double mDoubleValue;
bool mBoolValue;
char mCharValue;
char16_t mWCharValue;
nsIID mIDValue;
nsAString* mAStringValue;
nsAUTF8String* mUTF8StringValue;
nsACString* mCStringValue;
struct {
// This is an owning reference that cannot be an nsCOMPtr because
// nsDiscriminatedUnion needs to be POD. AddRef/Release are manually
// called on this.
nsISupports* MOZ_OWNING_REF mInterfaceValue;
nsIID mInterfaceID;
} iface;
struct {
nsIID mArrayInterfaceID;
void* mArrayValue;
uint32_t mArrayCount;
uint16_t mArrayType;
} array;
struct {
char* mStringValue;
uint32_t mStringLength;
} str;
struct {
char16_t* mWStringValue;
uint32_t mWStringLength;
} wstr;
} u;
uint16_t mType;
};
Minimal test - lines (200, 209)
path: .spaces[3].metrics.mi.mi_visual_studio
old: 61.59833236701212
new: 64.60874757766398
path: .spaces[3].metrics.mi.mi_sei
old: 76.46639848908683
new: 83.99493832166654
path: .spaces[3].metrics.mi.mi_original
old: 105.33314834759072
new: 110.4809583578054
path: .spaces[3].metrics.cyclomatic.average
old: 2.0
new: 1.0
path: .spaces[3].metrics.cyclomatic.sum
old: 2.0
new: 3.0
path: .spaces[3].metrics.halstead.n2
old: 18.0
new: 4.0
path: .spaces[3].metrics.halstead.purity_ratio
old: 2.0527394393632634
new: 1.2568856570183284
path: .spaces[3].metrics.halstead.vocabulary
old: 31.0
new: 11.0
path: .spaces[3].metrics.halstead.n1
old: 13.0
new: 7.0
path: .spaces[3].metrics.halstead.volume
old: 297.2517786232125
new: 76.10749561002054
path: .spaces[3].metrics.halstead.N1
old: 32.0
new: 15.0
path: .spaces[3].metrics.halstead.length
old: 60.0
new: 22.0
path: .spaces[3].metrics.halstead.effort
old: 3005.545761634704
new: 466.15841061137576
path: .spaces[3].metrics.halstead.difficulty
old: 10.11111111111111
new: 6.125
path: .spaces[3].metrics.halstead.bugs
old: 0.06942155038225493
new: 0.020040155857929183
path: .spaces[3].metrics.halstead.estimated_program_length
old: 123.1643663617958
new: 27.651484454403228
path: .spaces[3].metrics.halstead.level
old: 0.09890109890109892
new: 0.16326530612244897
path: .spaces[3].metrics.halstead.N2
old: 28.0
new: 7.0
path: .spaces[3].metrics.halstead.time
old: 166.97476453526133
new: 25.897689478409763
path: .spaces[3].metrics.nom.functions
old: 1.0
new: 2.0
path: .spaces[3].metrics.nom.total
old: 1.0
new: 2.0
path: .spaces[3].metrics.loc.blank
old: 1.0
new: 2.0
path: .spaces[3].metrics.loc.sloc
old: 9.0
new: 10.0
path: .spaces[3].metrics.loc.lloc
old: 3.0
new: 0.0
path: .spaces[3].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[3].metrics.nexits.average
old: 1.0
new: 0.0
path: .spaces[3].metrics.cognitive.average
old: 1.0
new: 0.0
path: .spaces[3].metrics.cognitive.sum
old: 1.0
new: 0.0
path: .spaces[3].metrics.nargs.sum
old: 4.0
new: 0.0
path: .spaces[3].metrics.nargs.average
old: 4.0
new: 0.0
Code
class nsVariantCC final : public nsVariantBase {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsVariantCC)
nsVariantCC() = default;
private:
~nsVariantCC() = default;
};