Skip to content

Commit

Permalink
Count coding-rules complaints
Browse files Browse the repository at this point in the history
This may or not prove useful someday, but it's so easy to gather a
little more information that there's no reason not to do so.
  • Loading branch information
Gregory W. Chicares committed Jun 28, 2021
1 parent 8882ef7 commit a9bc62f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test_coding_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include <stdexcept> // runtime_error
#include <string>

// Count complaints that are not so severe as to halt processing a file.
int complaint_count {0};

std::string my_taboo_indulgence(); // See 'my_test_coding_rules.cpp'.

std::map<std::string, bool> my_taboos(); // See 'my_test_coding_rules.cpp'.
Expand Down Expand Up @@ -259,11 +262,9 @@ bool file::phyloanalyze(std::string const& s) const
return boost::regex_search(file_name(), boost::regex(s));
}

bool error_flag = false;

void complain(file const& f, std::string const& complaint)
{
error_flag = true;
++complaint_count;
std::cout << "File '" << f.full_name() << "' " << complaint << std::endl;
}

Expand Down Expand Up @@ -1277,6 +1278,8 @@ statistics process_file(std::string const& file_path)

int try_main(int argc, char* argv[])
{
complaint_count = 0;
bool error_flag = false;
statistics z;
for(int j = 1; j < argc; ++j)
{
Expand All @@ -1292,5 +1295,5 @@ int try_main(int argc, char* argv[])
}
}
z.print_summary();
return error_flag ? EXIT_FAILURE : EXIT_SUCCESS;
return (error_flag || complaint_count) ? EXIT_FAILURE : EXIT_SUCCESS;
}

0 comments on commit a9bc62f

Please sign in to comment.