diff --git a/cmd/joj3/main_test.go b/cmd/joj3/main_test.go index 33f16a0..44b4821 100644 --- a/cmd/joj3/main_test.go +++ b/cmd/joj3/main_test.go @@ -53,9 +53,12 @@ func TestMain(t *testing.T) { {Score: 100, Comment: "executor status: run time: \\d+ ns, memory: \\d+ bytes"}, }}, }}, - {"clang_tidy", []stage.StageResult{ + {"clang-tidy", []stage.StageResult{ + {Name: "prepare", Results: []stage.ParserResult{ + {Score: 0, Comment: ""}, + }}, {Name: "clang-tidy", Results: []stage.ParserResult{ - {Score: -200, Comment: ""}, + {Score: 10, Comment: ""}, }}, }}, {"compile_error", []stage.StageResult{ diff --git a/examples/clang_tidy/.gitignore b/examples/clang-tidy/.gitignore similarity index 100% rename from examples/clang_tidy/.gitignore rename to examples/clang-tidy/.gitignore diff --git a/examples/clang-tidy/CMakeLists.txt b/examples/clang-tidy/CMakeLists.txt new file mode 100644 index 0000000..99463a8 --- /dev/null +++ b/examples/clang-tidy/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.0) + +project(MyProject) + +add_executable(main sillycode.cpp) diff --git a/examples/clang-tidy/conf.toml b/examples/clang-tidy/conf.toml new file mode 100644 index 0000000..5391357 --- /dev/null +++ b/examples/clang-tidy/conf.toml @@ -0,0 +1,62 @@ +skipGitea = true +[[stages]] +name = "prepare" +[stages.executor] +name = "sandbox" +[stages.executor.with.default] +args = ["cmake", "-S", ".", "-DDRONE=ON", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-B", "build"] +env = ["PATH=/usr/bin:/bin"] +cpuLimit = 10_000_000_000 +memoryLimit = 104_857_600 +procLimit = 50 +copyInCwd = true +copyOut = ["stdout"] +copyOutCached = ["build/compile_commands.json"] +[stages.executor.with.default.stdin] +content = "" +[stages.executor.with.default.stdout] +name = "stdout" +max = 65_536 +[stages.executor.with.default.stderr] +name = "stderr" +max = 65_536 +[stages.parser] +name = "dummy" +[stages.parser.with] +score = 0 +comment = "" +[[stages]] +name = "clang-tidy" +[stages.executor] +name = "sandbox" +[stages.executor.with.default] +args = ["clang-tidy", "--header-filter=.*", "--quiet", "-checks=*", "sillycode.cpp", "-p", "build"] +env = ["PATH=/usr/bin:/bin"] +cpuLimit = 10_000_000_000 +memoryLimit = 104_857_600 +procLimit = 50 +copyInCwd = true +copyOut = ["stdout"] +[stages.executor.with.default.stdin] +content = "" +[stages.executor.with.default.stdout] +name = "stdout" +max = 65_536 +[stages.executor.with.default.stderr] +name = "stderr" +max = 65_536 +[stages.executor.with.default.copyInCached] +"build/compile_commands.json" = "build/compile_commands.json" +[stages.parser] +name = "clang-tidy" +[stages.parser.with] +score = 100 +[[stages.parser.with.matches]] +keyword = ["cppcoreguidelines-avoid-non-const-global-variables"] +score = 5 +[[stages.parser.with.matches]] +keyword = ["readability-identifier-length","misc-use-anonymous-namespace"] +score = 2 +[[stages.parser.with.matches]] +keyword = ["llvmlibc-implementation-in-namespace"] +score = 0 diff --git a/examples/clang_tidy/sillycode.cpp b/examples/clang-tidy/sillycode.cpp similarity index 100% rename from examples/clang_tidy/sillycode.cpp rename to examples/clang-tidy/sillycode.cpp diff --git a/examples/clang_tidy/clangtidy_result.json b/examples/clang_tidy/clangtidy_result.json new file mode 100644 index 0000000..19acf18 --- /dev/null +++ b/examples/clang_tidy/clangtidy_result.json @@ -0,0 +1,1996 @@ +[ + { + "type": "issue", + "check_name": "clang-diagnostic-error", + "description": "'gtest/test.h' file not found", + "content": { + "body": "```\n#include \n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 3 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "critical", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\n Month month() const; // do\n\n ^\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 9 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\n int month(); // don't\n\n ~~~ ^\n\n auto -> int\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 10 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-runtime-references", + "description": "non-const reference parameter 'v', make it const or use a pointer", + "content": { + "body": "```\nvoid do_something(vector& v)\n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 14 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-unused-parameters", + "description": "parameter 'v' is unused", + "content": { + "body": "```\nvoid do_something(vector& v)\n\n ^\n\n /*v*/\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 14 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-init-variables", + "description": "variable 'val' is not initialized", + "content": { + "body": "```\n string val;\n\n ^\n\n = 0\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 16 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-special-member-functions", + "description": "class 'X' defines a copy constructor and a copy assignment operator but does not define a destructor, a move constructor or a move assignment operator", + "content": { + "body": "```\nstruct X {\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 28 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-special-member-functions", + "description": "class 'X' defines a copy constructor and a copy assignment operator but does not define a destructor, a move constructor or a move assignment operator", + "content": { + "body": "```\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 28 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-non-private-member-variables-in-classes", + "description": "member variable 'ch' has public visibility", + "content": { + "body": "```\n char ch;\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 29 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-non-private-member-variables-in-classes", + "description": "member variable 'i' has public visibility", + "content": { + "body": "```\n int i;\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 30 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-non-private-member-variables-in-classes", + "description": "member variable 's' has public visibility", + "content": { + "body": "```\n string s;\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 31 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-non-private-member-variables-in-classes", + "description": "member variable 'ch2' has public visibility", + "content": { + "body": "```\n char ch2;\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 32 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\n X& operator=(const X& a); // NOLINT(clang-analyzer-valist.Uninitialized)\n\n ~~ ^\n\n auto -> X&\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 34 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\nX waste(const char* p)\n\n~ ^\n\nauto -> X\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 38 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-init-variables", + "description": "variable 'n' is not initialized", + "content": { + "body": "```\n int n = strlen(p);\n\n ^\n\n = 0\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 41 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-owning-memory", + "description": "initializing non-owner 'char *' with a newly created 'gsl::owner<>'", + "content": { + "body": "```\n auto buf = new char[n];\n\n ^\n\n../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp:42:5: type deduction did not result in an owner\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 42 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [ + { + "lines": { + "begin": 42 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + } + ] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "llvm-qualified-auto", + "description": "'auto buf' can be declared as 'auto *buf'", + "content": { + "body": "```\n auto buf = new char[n];\n\n ^\n\nnote: this fix will not be applied because it overlaps with another fix\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 42 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-qualified-auto", + "description": "'auto buf' can be declared as 'auto *buf'", + "content": { + "body": "```\nnote: this fix will not be applied because it overlaps with another fix\n\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 42 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-braces-around-statements", + "description": "statement should be inside braces", + "content": { + "body": "```\n for (int i = 0; i < n; ++i) buf[i] = p[i];\n\n ^\n\n {\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 44 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-braces-around-statements", + "description": "statement should be inside braces", + "content": { + "body": "```\n for (int i = 0; i < n; ++i) buf[i] = p[i];\n\n ^\n\n {\n\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 44 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-pro-bounds-pointer-arithmetic", + "description": "do not use pointer arithmetic", + "content": { + "body": "```\n for (int i = 0; i < n; ++i) buf[i] = p[i];\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 44 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-pro-bounds-pointer-arithmetic", + "description": "do not use pointer arithmetic", + "content": { + "body": "```\n for (int i = 0; i < n; ++i) buf[i] = p[i];\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 44 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-owning-memory", + "description": "deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead", + "content": { + "body": "```\n delete buf;\n\n ^\n\n../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp:42:5: variable declared here\n auto buf = new char[n];\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 50 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [ + { + "lines": { + "begin": 42 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + } + ] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-avoid-magic-numbers", + "description": "666 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n int i {666};\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 71 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-magic-numbers", + "description": "666 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 71 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-explicit-constructor", + "description": "single-argument constructors must be marked explicit to avoid unintentional implicit conversions", + "content": { + "body": "```\n X2(int ii) :i{ii} {} // s and j initialized to their defaults\n\n ^\n\n explicit \n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 76 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-explicit-conversions", + "description": "single-argument constructors must be marked explicit to avoid unintentional implicit conversions", + "content": { + "body": "```\n X2(int ii) :i{ii} {} // s and j initialized to their defaults\n\n ^\n\n explicit \n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 76 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-default-member-init", + "description": "use default member initializer for 'i'", + "content": { + "body": "```\n int i;\n\n ^\n\n {ii}\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 81 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-default-member-init", + "description": "use default member initializer for 'j'", + "content": { + "body": "```\n int j;\n\n ^\n\n {jj}\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 83 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-pro-type-member-init", + "description": "constructor does not initialize these fields: s", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-explicit-constructor", + "description": "constructors that are callable with a single argument must be marked explicit to avoid unintentional implicit conversions", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^\n\n explicit \n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-explicit-conversions", + "description": "constructors that are callable with a single argument must be marked explicit to avoid unintentional implicit conversions", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^\n\n explicit \n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-member-init", + "description": "constructor does not initialize these fields: s", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "fuchsia-default-arguments-declarations", + "description": "declaring a parameter with a default argument is disallowed", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^ ~~~~~~\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-avoid-magic-numbers", + "description": "666 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-magic-numbers", + "description": "666 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-unused-parameters", + "description": "parameter 'ss' is unused", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^~\n\n /*ss*/\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "fuchsia-default-arguments-declarations", + "description": "declaring a parameter with a default argument is disallowed", + "content": { + "body": "```\n X3(int ii = 666, const string& ss = \"qqq\", int jj = 0)\n\n ^ ~~~~\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 85 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-special-member-functions", + "description": "class 'Foo' defines a move assignment operator but does not define a destructor, a copy constructor, a copy assignment operator or a move constructor", + "content": { + "body": "```\nclass Foo {\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 91 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-special-member-functions", + "description": "class 'Foo' defines a move assignment operator but does not define a destructor, a copy constructor, a copy assignment operator or a move constructor", + "content": { + "body": "```\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 91 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-noexcept-move", + "description": "move assignment operators should be marked noexcept", + "content": { + "body": "```\n Foo& operator=(Foo&& a);\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 95 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\n Foo& operator=(Foo&& a);\n\n ~~~~ ^\n\n auto -> Foo&\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 95 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "performance-noexcept-move-constructor", + "description": "move assignment operators should be marked noexcept", + "content": { + "body": "```\n Foo& operator=(Foo&& a);\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Performance" + ], + "location": { + "lines": { + "begin": 95 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-noexcept-move", + "description": "move assignment operators should be marked noexcept", + "content": { + "body": "```\nFoo& Foo::operator=(Foo&& a) // OK, but there is a cost\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 99 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\nFoo& Foo::operator=(Foo&& a) // OK, but there is a cost\n\n~~~~ ^\n\nauto -> Foo&\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 99 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "performance-noexcept-move-constructor", + "description": "move assignment operators should be marked noexcept", + "content": { + "body": "```\nFoo& Foo::operator=(Foo&& a) // OK, but there is a cost\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Performance" + ], + "location": { + "lines": { + "begin": 99 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-braces-around-statements", + "description": "statement should be inside braces", + "content": { + "body": "```\n if (this == &a) return *this; // this line is redundant\n\n ^\n\n {\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 101 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-braces-around-statements", + "description": "statement should be inside braces", + "content": { + "body": "```\n if (this == &a) return *this; // this line is redundant\n\n ^\n\n {\n\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 101 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-special-member-functions", + "description": "class 'Vector2' defines a move constructor and a move assignment operator but does not define a destructor, a copy constructor or a copy assignment operator", + "content": { + "body": "```\nclass Vector2 {\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 108 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-special-member-functions", + "description": "class 'Vector2' defines a move constructor and a move assignment operator but does not define a destructor, a copy constructor or a copy assignment operator", + "content": { + "body": "```\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 108 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-pro-type-member-init", + "description": "constructor does not initialize these fields: sz", + "content": { + "body": "```\n Vector2(Vector2&& a) { *this = a; } // just use the copy\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 110 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-member-init", + "description": "constructor does not initialize these fields: sz", + "content": { + "body": "```\n Vector2(Vector2&& a) { *this = a; } // just use the copy\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 110 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-noexcept-move", + "description": "move constructors should be marked noexcept", + "content": { + "body": "```\n Vector2(Vector2&& a) { *this = a; } // just use the copy\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 110 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "performance-noexcept-move-constructor", + "description": "move constructors should be marked noexcept", + "content": { + "body": "```\n Vector2(Vector2&& a) { *this = a; } // just use the copy\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Performance" + ], + "location": { + "lines": { + "begin": 110 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-noexcept-move", + "description": "move assignment operators should be marked noexcept", + "content": { + "body": "```\n Vector2& operator=(Vector2&& a) { *this = a; } // just use the copy\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 111 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\n Vector2& operator=(Vector2&& a) { *this = a; } // just use the copy\n\n ~~~~~~~~ ^\n\n auto -> Vector2&\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 111 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "performance-noexcept-move-constructor", + "description": "move assignment operators should be marked noexcept", + "content": { + "body": "```\n Vector2& operator=(Vector2&& a) { *this = a; } // just use the copy\n\n ^\n\n noexcept \n\n```" + }, + "categories": [ + "Performance" + ], + "location": { + "lines": { + "begin": 111 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-non-private-member-variables-in-classes", + "description": "member variable 'elem' has public visibility", + "content": { + "body": "```\n T* elem;\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 114 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-non-private-member-variables-in-classes", + "description": "member variable 'sz' has public visibility", + "content": { + "body": "```\n int sz;\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 115 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-runtime-references", + "description": "non-const reference parameter 'a', make it const or use a pointer", + "content": { + "body": "```\nvoid f2(N::X& a, N::X& b)\n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 118 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-runtime-references", + "description": "non-const reference parameter 'b', make it const or use a pointer", + "content": { + "body": "```\nvoid f2(N::X& a, N::X& b)\n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 118 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-runtime-references", + "description": "non-const reference parameter 'a', make it const or use a pointer", + "content": { + "body": "```\nvoid f3(N::X& a, N::X& b)\n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 123 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-unused-parameters", + "description": "parameter 'a' is unused", + "content": { + "body": "```\nvoid f3(N::X& a, N::X& b)\n\n ^\n\n /*a*/\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 123 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-runtime-references", + "description": "non-const reference parameter 'b', make it const or use a pointer", + "content": { + "body": "```\nvoid f3(N::X& a, N::X& b)\n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 123 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "misc-unused-parameters", + "description": "parameter 'b' is unused", + "content": { + "body": "```\nvoid f3(N::X& a, N::X& b)\n\n ^\n\n /*b*/\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 123 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-macro-usage", + "description": "macro 'RED' used to declare a constant; consider using a 'constexpr' constant", + "content": { + "body": "```\n#define RED 0xFF0000\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 131 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-macro-usage", + "description": "macro 'GREEN' used to declare a constant; consider using a 'constexpr' constant", + "content": { + "body": "```\n#define GREEN 0x00FF00\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 132 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-macro-usage", + "description": "macro 'BLUE' used to declare a constant; consider using a 'constexpr' constant", + "content": { + "body": "```\n#define BLUE 0x0000FF\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 133 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-macro-usage", + "description": "macro 'RED' used to declare a constant; consider using a 'constexpr' constant", + "content": { + "body": "```\n#define RED 0\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 137 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-macro-usage", + "description": "macro 'PURPLE' used to declare a constant; consider using a 'constexpr' constant", + "content": { + "body": "```\n#define PURPLE 1\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 138 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-macro-usage", + "description": "macro 'BLUE' used to declare a constant; consider using a 'constexpr' constant", + "content": { + "body": "```\n#define BLUE 2\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 139 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-runtime-references", + "description": "non-const reference parameter at index 0, make it const or use a pointer", + "content": { + "body": "```\nvoid reseat(unique_ptr&); // \"will\" or \"might\" reseat pointer\n\n ^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 168 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-avoid-c-arrays", + "description": "do not declare C-style arrays, use std::array<> instead", + "content": { + "body": "```\nint buf[max]; // OK, but suspicious: uninitialized\n\n^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 171 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-avoid-c-arrays", + "description": "do not declare C-style arrays, use std::array<> instead", + "content": { + "body": "```\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 171 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-avoid-c-arrays", + "description": "do not declare C-style arrays, use std::array<> instead", + "content": { + "body": "```\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 171 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-avoid-c-arrays", + "description": "do not declare C-style arrays, use std::array<> instead", + "content": { + "body": "```\nint buf[max] = {0}; // better in some situations\n\n^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 175 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-avoid-c-arrays", + "description": "do not declare C-style arrays, use std::array<> instead", + "content": { + "body": "```\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 175 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-avoid-c-arrays", + "description": "do not declare C-style arrays, use std::array<> instead", + "content": { + "body": "```\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 175 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-multiway-paths-covered", + "description": "potential uncovered code path; add a default label", + "content": { + "body": "```\n switch (n) { // good\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 218 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-avoid-magic-numbers", + "description": "7 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n case 7: // ...\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 220 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-magic-numbers", + "description": "7 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 220 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-special-member-functions", + "description": "class 'base' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator", + "content": { + "body": "```\nclass base { public: virtual ~base() = 0; };\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 230 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "hicpp-special-member-functions", + "description": "class 'base' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator", + "content": { + "body": "```\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 230 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "modernize-use-trailing-return-type", + "description": "use a trailing return type for this function", + "content": { + "body": "```\n std::string get_s() { return s; }\n\n ^\n\n```" + }, + "categories": [ + "Compatibility" + ], + "location": { + "lines": { + "begin": 237 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "fuchsia-statically-constructed-objects", + "description": "static objects are disallowed; if possible, use a constexpr constructor instead", + "content": { + "body": "```\nderived1 d1;\n\n^\n\n```" + }, + "categories": [ + "Bug Risk" + ], + "location": { + "lines": { + "begin": 240 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-pro-type-cstyle-cast", + "description": "do not use C-style cast to convert between unrelated types", + "content": { + "body": "```\nderived2* p2 = (derived2*)(p); // BAD, tries to treat d1 as a derived2, which it is not\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 243 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-readability-casting", + "description": "C-style casts are discouraged; use reinterpret_cast", + "content": { + "body": "```\nderived2* p2 = (derived2*)(p); // BAD, tries to treat d1 as a derived2, which it is not\n\n ^~~~~~~~~~~\n\n reinterpret_cast\n\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 243 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "google-readability-casting", + "description": "C-style casts are discouraged; use const_cast", + "content": { + "body": "```\n (int&)(i) = 42; // BAD\n\n ^~~~~~\n\n const_cast\n\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 247 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "cppcoreguidelines-avoid-magic-numbers", + "description": "42 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n (int&)(i) = 42; // BAD\n\n ^\n\n```" + }, + "categories": [ + "Style" + ], + "location": { + "lines": { + "begin": 247 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + }, + { + "type": "issue", + "check_name": "readability-magic-numbers", + "description": "42 is a magic number; consider replacing it with a named constant", + "content": { + "body": "```\n```" + }, + "categories": [ + "Clarity" + ], + "location": { + "lines": { + "begin": 247 + }, + "path": "../home/zjche/Desktop/JOJ3/examples/clang_tidy/sillycode.cpp" + }, + "trace": { + "locations": [] + }, + "severity": "major", + "fingerprint": "" + } +] diff --git a/examples/clang_tidy/conf.toml b/examples/clang_tidy/conf.toml deleted file mode 100644 index c8ca732..0000000 --- a/examples/clang_tidy/conf.toml +++ /dev/null @@ -1,32 +0,0 @@ -skipGitea = true -[[stages]] -name = "clang-tidy" -[stages.executor] -name = "clang-tidy" -[stages.executor.with.default] -args = ["clang-tidy", "--header-filter=.*", "--quiet", "-checks=*", "sillycode.cpp"] -env = ["PATH=/usr/bin:/bin"] -[stages.executor.with.default.copyIn.dummy] -src = "./../../build/dummy" -copyOut = ["stdout", "stderr"] -[stages.executor.with.default.stdin] -content = "" -[stages.executor.with.default.stdout] -name = "stdout" -max = 65_536 -[stages.executor.with.default.stderr] -name = "stderr" -max = 65_536 -[stages.parser] -name = "clang-tidy" -[stages.parser.with] -score = 100 -[[stages.parser.with.matches]] -keyword = ["cppcoreguidelines-avoid-non-const-global-variables"] -score = 5 -[[stages.parser.with.matches]] -keyword = ["readability-identifier-length","misc-use-anonymous-namespace"] -score = 2 -[[stages.parser.with.matches]] -keyword = ["llvmlibc-implementation-in-namespace"] -score = 0 diff --git a/internal/parsers/clang_tidy/convert.go b/internal/parsers/clang_tidy/convert.go index ab63b86..63bafe0 100644 --- a/internal/parsers/clang_tidy/convert.go +++ b/internal/parsers/clang_tidy/convert.go @@ -2,7 +2,6 @@ package clang_tidy import ( - "os" "path/filepath" "regexp" "strconv" @@ -111,7 +110,8 @@ func group_messages(messages []ClangMessage) []ClangMessage { } func convert_paths_to_relative(messages *[]ClangMessage) { - currentDir, _ := os.Getwd() + // currentDir, _ := os.Getwd() + currentDir := "/w" for i := range *messages { (*messages)[i].filepath, _ = filepath.Rel(currentDir, (*messages)[i].filepath) } diff --git a/internal/parsers/clang_tidy/parser.go b/internal/parsers/clang_tidy/parser.go index 2ce969e..76fcb42 100644 --- a/internal/parsers/clang_tidy/parser.go +++ b/internal/parsers/clang_tidy/parser.go @@ -2,12 +2,10 @@ package clang_tidy import ( "encoding/json" - "fmt" "os" "strings" "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage" - "github.com/criyle/go-judge/envexec" ) type Match struct { @@ -24,7 +22,6 @@ type ClangTidy struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { stdout := executorResult.Files["stdout"] - stderr := executorResult.Files["stderr"] lines := strings.SplitAfter(stdout, "\n") messages := parse_lines(lines) @@ -39,15 +36,15 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { encoder.SetIndent("", " ") _ = encoder.Encode(formatted_messages) - if executorResult.Status != stage.Status(envexec.StatusAccepted) { - return stage.ParserResult{ - Score: 0, - Comment: fmt.Sprintf( - "Unexpected executor status: %s.\nStderr: %s", - executorResult.Status, stderr, - ), - } - } + // if executorResult.Status != stage.Status(envexec.StatusAccepted) { + // return stage.ParserResult{ + // Score: 0, + // Comment: fmt.Sprintf( + // "Unexpected executor status: %s.\nStderr: %s", + // executorResult.Status, stderr, + // ), + // } + // } return stage.ParserResult{ Score: get_score(formatted_messages, conf), Comment: "",