LoginSignup
0
2

More than 3 years have passed since last update.

cpp lint の各 filter について

Last updated at Posted at 2020-12-23

c++ の linter として cpplint が存在する。
これは Google Guideline に沿ったコードになっているかをチェックしてくれるものだが、はっきり言って Google Guideline は厳しすぎるので Visual Studio の Default formatter で開発してる場合には使い物にならない。

一応 --filter=xxx でチェック内容の On/Off は可能なのだが、各項目が何を意味するかのドキュメントが見つからなかったので、コードから表示されるエラー内容を抜き出した。

build/c++11
   - <%s> is an unapproved C++11 header.
   - std::%s is an unapproved C++11 class or function. Send c-style an example of where it would make your code more readable and they may let you use it.
build/c++14
   - <%s> is an unapproved C++14 header.
build/c++tr1
   - C++ TR1 headers such as <%s> are unapproved.
build/class
   - Failed to find complete declaration of class %s
build/deprecated
   - >? and <? (max and min) operators are non-standard and deprecated.
build/endif_comment
   - Uncommented text after #endif is non-standard. Use a comment.
build/explicit_make_pair
   - For C++11-compatibility omit template arguments from make_pair OR use pair directly OR if appropriate construct a pair directly
build/forward_decl
   - Inner-style forward declarations are invalid. Remove this line.
build/header_guard
   - No #ifndef header guard found suggested CPP variable is: %s
   - #ifndef header guard has wrong style please use: %s
   - #endif line should be "#endif // %s"
   - #endif line should be "#endif /* %s */"
   - #endif line should be "#endif // %s"
build/include
   - %s should include its header file %s
   - Include the directory when naming .h files
   - "%s" already included at %s:%s
   - Do not include .cc files from other packages
build/include_alpha
   - Include "%s" not in alphabetical order
build/include_order
   - %s. Should be: %s.h c system c++ system other.
build/include_what_you_use
   - Add #include %s for %s
build/namespaces
   - Failed to find complete declaration of namespace %s
   - Do not use namespace using-directives. Use using-declarations instead.
   - Do not use unnamed namespaces in header files. See https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces for more information.
build/printf_format
   - %q in format strings is deprecated.  Use %ll instead.
   - %N$ formats are unconventional.  Try rewriting to avoid them.
   - %, [, ( and { are undefined character escapes. Unescape them.
build/storage_class
   - Storage-class specifier (static extern typedef etc) should be
legal/copyright
   - No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>"
readability/alt_tokens
   - Use operator %s instead of %s
readability/braces
   - If an else has a brace on one side it should have it on both
   - If/else bodies with multiple statements require braces
   - Else clause should be indented at the same level as if. Ambiguous nested if/else chains require braces.
   - If/else bodies with multiple statements require braces
   - "You don't need a ; after a }
   - Did you mean "else if"? If not start a new line for "if".
readability/casting
   - Using deprecated casting style. Use static_cast<%s>(...) instead
   - Are you taking an address of something dereferenced from a cast? Wrapping the dereferenced expression in parentheses will make the binding more obvious
   - Using C-style cast. Use %s<%s>(...) instead
readability/check
   - Consider using %s instead of %s(a %s b)
readability/constructors
   - %s should be the last thing in the class
readability/fn_size
   - Small and focused functions are preferred: %s has %d non-comment lines (error triggered by exceeding %d lines).
   - Lint failed to find start of function body.
readability/inheritance
   - "virtual" is redundant since function is already declared as "%s"
   - "override" is redundant since function is already declared as "final"
readability/multiline_comment
   - Could not find end of multi-line comment
   - Complex multi-line /*...*/-style comment found. Lint may give bogus warnings. Consider replacing these with //-style comments with #if 0...#endif or with more clearly structured multi-line comments.
readability/multiline_string
   - Multi-line string ("...") found. This lint script doesn't
readability/namespace
   - Namespace should be terminated with "// namespace %s"
   - Anonymous namespace should be terminated with "// namespace" or "// anonymous namespace"
   - Anonymous namespace should be terminated with "// namespace"
readability/nolint
   - Unknown NOLINT error category: %s
readability/nul
   - Line contains NUL byte.
readability/todo
   - Missing username in TODO; it should look like "// TODO(my_username): Stuff."
readability/utf8
   - Line contains invalid UTF-8 (or Unicode replacement character).
runtime/arrays
   - Do not use variable-length arrays. Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size.
runtime/casting
   - Are you taking an address of a cast? This is dangerous: could be a temp var. Take the address before doing the cast rather than after
runtime/explicit
   - Constructors callable with one argument should be marked explicit.
   - Single-parameter constructors should be marked explicit.
   - Zero-parameter constructors should not be marked explicit.
runtime/indentation_namespace
   - Do not indent within a namespace
runtime/init
   - You seem to be initializing a member variable with itself.
runtime/int
   - Use "unsigned short" for ports not "short"
   - Use int16/int64/etc rather than the C type %s
runtime/invalid_increment
   - Changing pointer instead of value (or unused value of operator*).
runtime/member_string_references
   - const string& members are dangerous. It is much better to use alternatives such as pointers or simple constants.
runtime/memset
   - Did you mean "memset(%s    0 %s)"?
runtime/operator
   - Unary operator& is dangerous. Do not use it.
runtime/printf
   - Potential format string bug. Do %s("%%s" %s) instead.
   - If you can use sizeof(%s) instead of %s as the 2nd arg
   - Never use sprintf. Use snprintf instead.
   - Almost always snprintf is better than %s
runtime/printf_format
   - %q in format strings is deprecated. Use %ll instead.
   - %N$ formats are unconventional. Try rewriting to avoid them.
runtime/references
   - Is this a non-const reference? If so, make const or use a pointer: %s
runtime/string
   - For a static/global string constant use a C style string instead: "%schar%s %s[]".
   - Static/global string variables are not permitted.
runtime/threadsafe_fn
   - Consider using %s ...) instead of %s ...) for improved thread safety.
runtime/vlog
   - VLOG() should be used with numeric verbosity level.
whitespace/blank_line
   - Redundant blank line at the start of a code block should be deleted.
   - Redundant blank line at the end of a code block should be deleted.
   - Do not leave a blank line after "%s:"
   - "%s:" should be preceded by a blank line
whitespace/braces
   - Extra space before [
   - Missing space before {
   - Missing space before else
   - { should almost always be at the end of the previous line
whitespace/comma
   - Missing space after
   - At least two spaces is best between code and comments
whitespace/comments
   - Should have a space between // and comment
whitespace/empty_conditional_body
   - Empty conditional bodies should use {}
whitespace/empty_if_body
   - If statement had no body and no else clause
whitespace/empty_loop_body
   - Empty loop bodies should use {} or continue
whitespace/end_of_line
   - Line ends in whitespace. Consider deleting these extra spaces.
whitespace/ending_newline
   - Could not find a newline character at the end of the file.
whitespace/forcolon
   - Missing space around colon in range-based for loop
whitespace/indent
   - Closing brace should be aligned with beginning of %s
   - %s%s: should be indented +1 space inside %s
   - Weird number of spaces at line-start. Are you using a 2-space indent?
whitespace/line_length
   - Lines should be <= %i characters long
whitespace/newline
   - An else should appear on the same line as the preceding }
   - Else clause should never be on same line as else (use 2 lines)
   - do/while clauses should not be on a single line
   - More than one command on the same line
whitespace/operators
   - Missing spaces around =
   - Missing spaces around %s
   - Missing spaces around <
   - Missing spaces around >
   - Missing spaces around <<
   - Missing spaces around >>
   - Extra space for operator %s
whitespace/parens
   - Extra space after ( in function call
   - Extra space after (
   - Extra space before ( in function call
   - Closing ) should be moved to the previous line
   - Extra space before )
   - Missing space before ( in %s
   - Mismatching spaces inside () in %s
   - Should have zero or one spaces inside ( and ) in %s
whitespace/semicolon
   - Missing space after ;
   - Semicolon defining empty statement. Use {} instead.
   - Line contains only semicolon. If this should be an empty statement use {} instead.
   - Extra space before last semicolon. If this should be an empty statement use {} instead.
whitespace/tab
   - Tab found; better to use spaces
whitespace/todo
   - Too many spaces before TODO
   - TODO(my_username) should be followed by a space

おすすめ設定を書いてくれている人もいる。下記など。
https://github.com/sider/runners/blob/master/images/cpplint/sider_recommended_CPPLINT.cfg

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2