Global Metrics
path: .metrics.halstead.time
old: 518097.99773496366
new: 418.6038557338901
path: .metrics.halstead.bugs
old: 14.768453659695814
new: 0.12811379562100245
path: .metrics.halstead.volume
old: 64875.50306975851
new: 761.0979195161638
path: .metrics.halstead.n2
old: 362.0
new: 30.0
path: .metrics.halstead.difficulty
old: 143.74861878453038
new: 9.9
path: .metrics.halstead.estimated_program_length
old: 3249.917947726632
new: 175.7360428812364
path: .metrics.halstead.N2
old: 3061.0
new: 66.0
path: .metrics.halstead.n1
old: 34.0
new: 9.0
path: .metrics.halstead.vocabulary
old: 396.0
new: 39.0
path: .metrics.halstead.N1
old: 4457.0
new: 78.0
path: .metrics.halstead.level
old: 0.006956588581201837
new: 0.101010101010101
path: .metrics.halstead.purity_ratio
old: 0.4322849092480224
new: 1.2203891866752528
path: .metrics.halstead.effort
old: 9325763.959229346
new: 7534.869403210021
path: .metrics.halstead.length
old: 7518.0
new: 144.0
path: .metrics.loc.sloc
old: 1741.0
new: 141.0
path: .metrics.loc.lloc
old: 645.0
new: 0.0
path: .metrics.loc.blank
old: 85.0
new: 6.0
path: .metrics.loc.cloc
old: 101.0
new: 94.0
path: .metrics.loc.ploc
old: 1555.0
new: 41.0
path: .metrics.nexits.average
old: 0.896551724137931
new: null
path: .metrics.nexits.sum
old: 26.0
new: 0.0
path: .metrics.nargs.sum
old: 244.0
new: 0.0
path: .metrics.nargs.average
old: 8.413793103448276
new: null
path: .metrics.mi.mi_visual_studio
old: 0.0
new: 32.67212120630862
path: .metrics.mi.mi_original
old: -90.30505397364806
new: 55.869327262787735
path: .metrics.mi.mi_sei
old: -151.10149393989118
new: 52.784226130968634
path: .metrics.nom.total
old: 29.0
new: 0.0
path: .metrics.nom.functions
old: 29.0
new: 0.0
path: .metrics.cognitive.sum
old: 366.0
new: 0.0
path: .metrics.cognitive.average
old: 12.620689655172416
new: null
path: .metrics.cyclomatic.average
old: 11.612903225806452
new: 1.0
path: .metrics.cyclomatic.sum
old: 360.0
new: 2.0
Spaces Data
Minimal test - lines (15, 139)
path: .spaces[0].metrics.cyclomatic.sum
old: 359.0
new: 1.0
path: .spaces[0].metrics.cyclomatic.average
old: 11.966666666666669
new: 1.0
path: .spaces[0].metrics.halstead.n1
old: 34.0
new: 9.0
path: .spaces[0].metrics.halstead.n2
old: 357.0
new: 27.0
path: .spaces[0].metrics.halstead.N1
old: 4457.0
new: 77.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 3200.2552908609
new: 156.91128757139447
path: .spaces[0].metrics.halstead.effort
old: 9410275.51606543
new: 7425.735610404974
path: .spaces[0].metrics.halstead.purity_ratio
old: 0.4260190749282348
new: 1.1288581839668668
path: .spaces[0].metrics.halstead.level
old: 0.006873977086743044
new: 0.0967741935483871
path: .spaces[0].metrics.halstead.volume
old: 64686.01827737284
new: 718.6195752004813
path: .spaces[0].metrics.halstead.vocabulary
old: 391.0
new: 36.0
path: .spaces[0].metrics.halstead.time
old: 522793.0842258572
new: 412.5408672447208
path: .spaces[0].metrics.halstead.bugs
old: 14.857542159120664
new: 0.12687373744573122
path: .spaces[0].metrics.halstead.N2
old: 3055.0
new: 62.0
path: .spaces[0].metrics.halstead.difficulty
old: 145.47619047619048
new: 10.333333333333334
path: .spaces[0].metrics.halstead.length
old: 7512.0
new: 139.0
path: .spaces[0].metrics.loc.sloc
old: 1719.0
new: 125.0
path: .spaces[0].metrics.loc.lloc
old: 645.0
new: 0.0
path: .spaces[0].metrics.loc.cloc
old: 90.0
new: 87.0
path: .spaces[0].metrics.loc.blank
old: 83.0
new: 2.0
path: .spaces[0].metrics.loc.ploc
old: 1546.0
new: 36.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 0.0
new: 34.12233360082862
path: .spaces[0].metrics.mi.mi_original
old: -89.85382954007886
new: 58.34919045741694
path: .spaces[0].metrics.mi.mi_sei
old: -151.42416680172337
new: 56.656468361632086
path: .spaces[0].metrics.nom.functions
old: 29.0
new: 0.0
path: .spaces[0].metrics.nom.total
old: 29.0
new: 0.0
path: .spaces[0].metrics.nargs.sum
old: 244.0
new: 0.0
path: .spaces[0].metrics.nargs.average
old: 8.413793103448276
new: null
path: .spaces[0].metrics.nexits.average
old: 0.896551724137931
new: null
path: .spaces[0].metrics.nexits.sum
old: 26.0
new: 0.0
path: .spaces[0].metrics.cognitive.average
old: 12.620689655172416
new: null
path: .spaces[0].metrics.cognitive.sum
old: 366.0
new: 0.0
Code
class nsLinebreakConverter {
public:
// Note: enum must match char* array in GetLinebreakString
typedef enum {
eLinebreakAny, // any kind of linebreak (i.e. "don't care" source)
eLinebreakPlatform, // platform linebreak
eLinebreakContent, // Content model linebreak (LF)
eLinebreakNet, // Form submission linebreak (CRLF)
eLinebreakMac, // CR
eLinebreakUnix, // LF
eLinebreakWindows, // CRLF
eLinebreakSpace // space characters. Only valid as destination type
} ELinebreakType;
enum { kIgnoreLen = -1 };
/* ConvertLineBreaks
* Convert line breaks in the supplied string, allocating and returning
* a new buffer. Returns nullptr on failure.
* @param aSrc: the source string. if aSrcLen == kIgnoreLen this string is
* assumed to be null terminated, otherwise it must be at least
* aSrcLen long.
* @param aSrcBreaks: the line breaks in the source. If unknown, pass
* eLinebreakAny. If known, pass the known value, as this may
* be more efficient.
* @param aDestBreaks: the line breaks you want in the output.
* @param aSrcLen: length of the source. If -1, the source is assumed to be a
* null-terminated string.
* @param aOutLen: used to return character length of returned buffer, if not
* null.
*/
static char* ConvertLineBreaks(const char* aSrc, ELinebreakType aSrcBreaks,
ELinebreakType aDestBreaks,
int32_t aSrcLen = kIgnoreLen,
int32_t* aOutLen = nullptr);
/* ConvertUnicharLineBreaks
* Convert line breaks in the supplied string, allocating and returning
* a new buffer. Returns nullptr on failure.
* @param aSrc: the source string. if aSrcLen == kIgnoreLen this string is
* assumed to be null terminated, otherwise it must be at least
* aSrcLen long.
* @param aSrcBreaks: the line breaks in the source. If unknown, pass
* eLinebreakAny. If known, pass the known value, as this may
* be more efficient.
* @param aDestBreaks: the line breaks you want in the output.
* @param aSrcLen: length of the source, in characters. If -1, the source is
* assumed to be a null-terminated string.
* @param aOutLen: used to return character length of returned buffer, if not
* null.
*/
static char16_t* ConvertUnicharLineBreaks(const char16_t* aSrc,
ELinebreakType aSrcBreaks,
ELinebreakType aDestBreaks,
int32_t aSrcLen = kIgnoreLen,
int32_t* aOutLen = nullptr);
/* ConvertStringLineBreaks
* Convert line breaks in the supplied string, changing the string buffer
* (i.e. in-place conversion)
* @param ioString: the string to be converted.
* @param aSrcBreaks: the line breaks in the source. If unknown, pass
* eLinebreakAny. If known, pass the known value, as this may
* be more efficient.
* @param aDestBreaks: the line breaks you want in the output.
* @param aSrcLen: length of the source, in characters. If -1, the source is
* assumed to be a null-terminated string.
*/
static nsresult ConvertStringLineBreaks(nsString& aIoString,
ELinebreakType aSrcBreaks,
ELinebreakType aDestBreaks);
/* ConvertLineBreaksInSitu
* Convert line breaks in place if possible. NOTE: THIS MAY REALLOCATE THE
* BUFFER, BUT IT WON'T FREE THE OLD BUFFER (because it doesn't know how). So
* be prepared to keep a copy of the old pointer, and free it if this passes
* back a new pointer. ALSO NOTE: DON'T PASS A STATIC STRING POINTER TO THIS
* FUNCTION.
*
* @param ioBuffer: the source buffer. if aSrcLen == kIgnoreLen this string
* is assumed to be null terminated, otherwise it must be at
* least aSrcLen long.
* @param aSrcBreaks: the line breaks in the source. If unknown, pass
* eLinebreakAny. If known, pass the known value, as this may
* be more efficient.
* @param aDestBreaks: the line breaks you want in the output.
* @param aSrcLen: length of the source. If -1, the source is assumed to be a
* null-terminated string.
* @param aOutLen: used to return character length of returned buffer, if not
* null.
*/
static nsresult ConvertLineBreaksInSitu(char** aIoBuffer,
ELinebreakType aSrcBreaks,
ELinebreakType aDestBreaks,
int32_t aSrcLen = kIgnoreLen,
int32_t* aOutLen = nullptr);
/* ConvertUnicharLineBreaksInSitu
* Convert line breaks in place if possible. NOTE: THIS MAY REALLOCATE THE
* BUFFER, BUT IT WON'T FREE THE OLD BUFFER (because it doesn't know how). So
* be prepared to keep a copy of the old pointer, and free it if this passes
* back a new pointer.
*
* @param ioBuffer: the source buffer. if aSrcLen == kIgnoreLen this string
* is assumed to be null terminated, otherwise it must be at
* least aSrcLen long.
* @param aSrcBreaks: the line breaks in the source. If unknown, pass
* eLinebreakAny. If known, pass the known value, as this may
* be more efficient.
* @param aDestBreaks: the line breaks you want in the output.
* @param aSrcLen: length of the source in characters. If -1, the source is
* assumed to be a null-terminated string.
* @param aOutLen: used to return character length of returned buffer, if not
* null.
*/
static nsresult ConvertUnicharLineBreaksInSitu(char16_t** aIoBuffer,
ELinebreakType aSrcBreaks,
ELinebreakType aDestBreaks,
int32_t aSrcLen = kIgnoreLen,
int32_t* aOutLen = nullptr);
};