Global Metrics
path: .metrics.cyclomatic.average
old: 1.25
new: 2.4
path: .metrics.cyclomatic.sum
old: 5.0
new: 60.0
path: .metrics.mi.mi_original
old: 59.5574687809732
new: 28.55275418342231
path: .metrics.mi.mi_sei
old: 52.32462384771204
new: -8.772481586451352
path: .metrics.mi.mi_visual_studio
old: 34.82892911168023
new: 16.697517066328835
path: .metrics.halstead.vocabulary
old: 72.0
new: 138.0
path: .metrics.halstead.difficulty
old: 10.258620689655173
new: 39.58181818181818
path: .metrics.halstead.volume
old: 1240.154925289905
new: 5509.106454003081
path: .metrics.halstead.N2
old: 85.0
new: 311.0
path: .metrics.halstead.purity_ratio
old: 1.9555515752547543
new: 1.1362006532971942
path: .metrics.halstead.level
old: 0.09747899159663866
new: 0.025264124942581536
path: .metrics.halstead.N1
old: 116.0
new: 464.0
path: .metrics.halstead.n1
old: 14.0
new: 28.0
path: .metrics.halstead.estimated_program_length
old: 393.0658666262056
new: 880.5555063053255
path: .metrics.halstead.bugs
old: 0.18165834574261755
new: 1.207619214831696
path: .metrics.halstead.effort
old: 12722.27897495678
new: 218060.45000663103
path: .metrics.halstead.length
old: 201.0
new: 775.0
path: .metrics.halstead.time
old: 706.7932763864878
new: 12114.469444812836
path: .metrics.halstead.n2
old: 58.0
new: 110.0
path: .metrics.loc.ploc
old: 44.0
new: 142.0
path: .metrics.loc.sloc
old: 92.0
new: 177.0
path: .metrics.loc.blank
old: 11.0
new: 23.0
path: .metrics.loc.lloc
old: 3.0
new: 63.0
path: .metrics.loc.cloc
old: 37.0
new: 12.0
path: .metrics.nargs.sum
old: 0.0
new: 23.0
path: .metrics.nargs.average
old: 0.0
new: 1.15
path: .metrics.cognitive.sum
old: 0.0
new: 32.0
path: .metrics.cognitive.average
old: 0.0
new: 1.6
path: .metrics.nexits.average
old: 1.0
new: 1.2
path: .metrics.nexits.sum
old: 2.0
new: 24.0
path: .metrics.nom.functions
old: 2.0
new: 20.0
path: .metrics.nom.total
old: 2.0
new: 20.0
Spaces Data
Minimal test - lines (28, 33)
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 49.12871113600807
new: 981.7432475514064
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.004471319041702271
new: 0.032926383120867174
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 2.0
new: 9.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 1.944234353490973
new: 1.9296439363079512
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 7.0
new: 19.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 5.0
new: 19.0
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 13.60964047443681
new: 61.74860596185444
path: .spaces[0].spaces[0].metrics.halstead.length
old: 7.0
new: 32.0
path: .spaces[0].spaces[0].metrics.halstead.time
old: 2.7293728408893374
new: 54.541291530633686
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 19.651484454403228
new: 135.93368043019473
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 2.5
new: 7.222222222222222
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 2.0
new: 13.0
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.4
new: 0.13846153846153847
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 5.0
new: 10.0
path: .spaces[0].spaces[0].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 3.0
path: .spaces[0].spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.5
path: .spaces[0].spaces[0].metrics.cognitive.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 1.0
new: 2.0
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 1.0
new: 2.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 1.0
new: 3.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 3.0
new: 6.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 3.0
new: 6.0
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 122.75146225357946
new: 91.58245991751792
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 80.40121985172942
new: 67.68434360199267
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 137.4860859464573
new: 115.74022755940746
Code
bool IsFile(const std::string &Path) {
struct stat St;
if (stat(Path.c_str(), &St))
return false;
return S_ISREG(St.st_mode);
}
Minimal test - lines (35, 40)
path: .spaces[0].spaces[1].metrics.loc.lloc
old: 2.0
new: 3.0
path: .spaces[0].spaces[1].metrics.loc.sloc
old: 4.0
new: 6.0
path: .spaces[0].spaces[1].metrics.loc.ploc
old: 4.0
new: 6.0
path: .spaces[0].spaces[1].metrics.nexits.average
old: 1.0
new: 2.0
path: .spaces[0].spaces[1].metrics.nexits.sum
old: 1.0
new: 2.0
path: .spaces[0].spaces[1].metrics.cyclomatic.sum
old: 1.0
new: 3.0
path: .spaces[0].spaces[1].metrics.cyclomatic.average
old: 1.0
new: 1.5
path: .spaces[0].spaces[1].metrics.nargs.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[1].metrics.nargs.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[1].metrics.cognitive.sum
old: 0.0
new: 1.0
path: .spaces[0].spaces[1].metrics.cognitive.average
old: 0.0
new: 1.0
path: .spaces[0].spaces[1].metrics.halstead.volume
old: 62.907475208398566
new: 135.93368043019473
path: .spaces[0].spaces[1].metrics.halstead.purity_ratio
old: 2.068309379925304
new: 1.9296439363079512
path: .spaces[0].spaces[1].metrics.halstead.difficulty
old: 4.083333333333333
new: 7.222222222222222
path: .spaces[0].spaces[1].metrics.halstead.effort
old: 256.8721904342941
new: 981.7432475514064
path: .spaces[0].spaces[1].metrics.halstead.n1
old: 7.0
new: 10.0
path: .spaces[0].spaces[1].metrics.halstead.N1
old: 10.0
new: 19.0
path: .spaces[0].spaces[1].metrics.halstead.length
old: 17.0
new: 32.0
path: .spaces[0].spaces[1].metrics.halstead.level
old: 0.2448979591836735
new: 0.13846153846153847
path: .spaces[0].spaces[1].metrics.halstead.time
old: 14.270677246349672
new: 54.541291530633686
path: .spaces[0].spaces[1].metrics.halstead.bugs
old: 0.013469665311234006
new: 0.032926383120867174
path: .spaces[0].spaces[1].metrics.halstead.N2
old: 7.0
new: 13.0
path: .spaces[0].spaces[1].metrics.halstead.estimated_program_length
old: 35.161259458730164
new: 61.74860596185444
path: .spaces[0].spaces[1].metrics.halstead.vocabulary
old: 13.0
new: 19.0
path: .spaces[0].spaces[1].metrics.halstead.n2
old: 6.0
new: 9.0
path: .spaces[0].spaces[1].metrics.mi.mi_original
old: 126.77537335305064
new: 115.74022755940746
path: .spaces[0].spaces[1].metrics.mi.mi_sei
old: 107.29917031068469
new: 91.58245991751792
path: .spaces[0].spaces[1].metrics.mi.mi_visual_studio
old: 74.13764523570212
new: 67.68434360199267
Code
static bool IsDirectory(const std::string &Path) {
struct stat St;
if (stat(Path.c_str(), &St))
return false;
return S_ISDIR(St.st_mode);
}
Minimal test - lines (26, 175)
path: .spaces[0].metrics.nargs.average
old: 0.0
new: 1.15
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 23.0
path: .spaces[0].metrics.mi.mi_sei
old: 57.25868642231751
new: -17.626637724737254
path: .spaces[0].metrics.mi.mi_original
old: 64.07653738625666
new: 31.788394494535453
path: .spaces[0].metrics.mi.mi_visual_studio
old: 37.47165929020857
new: 18.58970438276927
path: .spaces[0].metrics.loc.blank
old: 10.0
new: 22.0
path: .spaces[0].metrics.loc.lloc
old: 3.0
new: 63.0
path: .spaces[0].metrics.loc.sloc
old: 72.0
new: 150.0
path: .spaces[0].metrics.loc.cloc
old: 26.0
new: 1.0
path: .spaces[0].metrics.loc.ploc
old: 36.0
new: 127.0
path: .spaces[0].metrics.nexits.average
old: 1.0
new: 1.2
path: .spaces[0].metrics.nexits.sum
old: 2.0
new: 24.0
path: .spaces[0].metrics.nom.functions
old: 2.0
new: 20.0
path: .spaces[0].metrics.nom.total
old: 2.0
new: 20.0
path: .spaces[0].metrics.cognitive.average
old: 0.0
new: 1.55
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 31.0
path: .spaces[0].metrics.halstead.bugs
old: 0.1771243761313666
new: 1.2225829823224792
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.812050954674317
new: 1.082619360031623
path: .spaces[0].metrics.halstead.time
old: 680.4980379377726
new: 12340.33349319409
path: .spaces[0].metrics.halstead.N2
old: 78.0
new: 305.0
path: .spaces[0].metrics.halstead.difficulty
old: 10.5
new: 41.05769230769231
path: .spaces[0].metrics.halstead.length
old: 193.0
new: 768.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 349.7258342521432
new: 831.4516685042864
path: .spaces[0].metrics.halstead.vocabulary
old: 66.0
new: 132.0
path: .spaces[0].metrics.halstead.n2
old: 52.0
new: 104.0
path: .spaces[0].metrics.halstead.level
old: 0.09523809523809525
new: 0.024355971896955503
path: .spaces[0].metrics.halstead.n1
old: 14.0
new: 28.0
path: .spaces[0].metrics.halstead.effort
old: 12248.964682879903
new: 222126.0028774936
path: .spaces[0].metrics.halstead.volume
old: 1166.5680650361817
new: 5410.094683667292
path: .spaces[0].metrics.halstead.N1
old: 115.0
new: 463.0
path: .spaces[0].metrics.cyclomatic.sum
old: 4.0
new: 58.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.3333333333333333
new: 2.4166666666666665
Code
namespace fuzzer {
bool IsFile(const std::string &Path) {
struct stat St;
if (stat(Path.c_str(), &St))
return false;
return S_ISREG(St.st_mode);
}
static bool IsDirectory(const std::string &Path) {
struct stat St;
if (stat(Path.c_str(), &St))
return false;
return S_ISDIR(St.st_mode);
}
size_t FileSize(const std::string &Path) {
struct stat St;
if (stat(Path.c_str(), &St))
return 0;
return St.st_size;
}
std::string Basename(const std::string &Path) {
size_t Pos = Path.rfind(GetSeparator());
if (Pos == std::string::npos) return Path;
assert(Pos < Path.size());
return Path.substr(Pos + 1);
}
void ListFilesInDirRecursive(const std::string &Dir, long *Epoch,
Vector *V, bool TopDir) {
auto E = GetEpoch(Dir);
if (Epoch)
if (E && *Epoch >= E) return;
DIR *D = opendir(Dir.c_str());
if (!D) {
Printf("%s: %s; exiting\n", strerror(errno), Dir.c_str());
exit(1);
}
while (auto E = readdir(D)) {
std::string Path = DirPlusFile(Dir, E->d_name);
if (E->d_type == DT_REG || E->d_type == DT_LNK ||
(E->d_type == DT_UNKNOWN && IsFile(Path)))
V->push_back(Path);
else if ((E->d_type == DT_DIR ||
(E->d_type == DT_UNKNOWN && IsDirectory(Path))) &&
*E->d_name != '.')
ListFilesInDirRecursive(Path, Epoch, V, false);
}
closedir(D);
if (Epoch && TopDir)
*Epoch = E;
}
void IterateDirRecursive(const std::string &Dir,
void (*DirPreCallback)(const std::string &Dir),
void (*DirPostCallback)(const std::string &Dir),
void (*FileCallback)(const std::string &Dir)) {
DirPreCallback(Dir);
DIR *D = opendir(Dir.c_str());
if (!D) return;
while (auto E = readdir(D)) {
std::string Path = DirPlusFile(Dir, E->d_name);
if (E->d_type == DT_REG || E->d_type == DT_LNK ||
(E->d_type == DT_UNKNOWN && IsFile(Path)))
FileCallback(Path);
else if ((E->d_type == DT_DIR ||
(E->d_type == DT_UNKNOWN && IsDirectory(Path))) &&
*E->d_name != '.')
IterateDirRecursive(Path, DirPreCallback, DirPostCallback, FileCallback);
}
closedir(D);
DirPostCallback(Dir);
}
char GetSeparator() {
return '/';
}
FILE* OpenFile(int Fd, const char* Mode) {
return fdopen(Fd, Mode);
}
int CloseFile(int fd) {
return close(fd);
}
int DuplicateFile(int Fd) {
return dup(Fd);
}
void RemoveFile(const std::string &Path) {
unlink(Path.c_str());
}
void RenameFile(const std::string &OldPath, const std::string &NewPath) {
rename(OldPath.c_str(), NewPath.c_str());
}
intptr_t GetHandleFromFd(int fd) {
return static_cast(fd);
}
std::string DirName(const std::string &FileName) {
char *Tmp = new char[FileName.size() + 1];
memcpy(Tmp, FileName.c_str(), FileName.size() + 1);
std::string Res = dirname(Tmp);
delete [] Tmp;
return Res;
}
std::string TmpDir() {
if (auto Env = getenv("TMPDIR"))
return Env;
return "/tmp";
}
bool IsInterestingCoverageFile(const std::string &FileName) {
if (FileName.find("compiler-rt/lib/") != std::string::npos)
return false; // sanitizer internal.
if (FileName.find("/usr/lib/") != std::string::npos)
return false;
if (FileName.find("/usr/include/") != std::string::npos)
return false;
if (FileName == "")
return false;
return true;
}
void RawPrint(const char *Str) {
mozilla::Unused << write(2, Str, strlen(Str));
}
void MkDir(const std::string &Path) {
mkdir(Path.c_str(), 0700);
}
void RmDir(const std::string &Path) {
rmdir(Path.c_str());
}
const std::string &getDevNull() {
static const std::string devNull = "/dev/null";
return devNull;
}
} // namespace fuzzer