[go: up one dir, main page]

Jump to content

Cpplint: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
KolbertBot (talk | contribs)
m Bot: HTTP→HTTPS (v461)
Repair, expand citation; prevent mid-code line breaks
Line 2: Line 2:
designed to ensure that [[C++]] code conforms to [https://google.github.io/styleguide/cppguide.html Google's coding style guides].
designed to ensure that [[C++]] code conforms to [https://google.github.io/styleguide/cppguide.html Google's coding style guides].


Therefore cpplint implements what Google considers to be ''"best practices"'' in C++ coding.
Therefore cpplint implements what Google considers best practices in C++ coding.
The script cpplint.py reads source code files and flags deviations from the style guide.
The script cpplint.py reads source code files and flags deviations from the style guide.
It also identifies [[syntax errors]].
It also identifies [[syntax errors]].
It is rules based, and uses a number of heuristics to identify bad code.<ref>{{cite web|url=http://etd.ohiolink.edu/send-pdf.cgi/Dutko%20Adam%20M.pdf?csu1313678735|last=Dutko|first=Adam|title=THE RELATIONAL DATABASE: A NEW STATIC ANALYSIS TOOL?}}</ref>
It is rules based, and uses a number of heuristics to identify bad code.<ref>{{cite thesis |url=https://engagedscholarship.csuohio.edu/cgi/viewcontent.cgi?context=etdarchive&article=1732#page=20 |format=PDF |last=Dutko |first=Adam M. |title=The Relational Database: a New Static Analysis Tool? |date=2011 |oclc=750403495 |issn=2572-3480 |number=733 |page=20 |type=Master of Science |publisher=Cleveland State University |dead-url=no |archive-url=https://web.archive.org/web/20180518113320/https://engagedscholarship.csuohio.edu/cgi/viewcontent.cgi?referer=&httpsredir=1&article=1732&context=etdarchive |archive-date=18 May 2018}}</ref>


cpplint.py suffers from both [[false positives]] and false negatives.
cpplint.py suffers from both [[false positives]] and false negatives.
False positives can be eliminated by tagging lines with <code>// NOLINT</code><ref>{{cite web|title=Google C++ Style Guide, section cpplint|first=Benjy|last=Weinberger|url=https://google.github.io/styleguide/cppguide.html#cpplint}}</ref> (or
False positives can be eliminated by tagging lines with {{nowrap|<code>// NOLINT</code>}}<ref>{{cite web|title=Google C++ Style Guide, section cpplint|first=Benjy|last=Weinberger|url=https://google.github.io/styleguide/cppguide.html#cpplint}}</ref> (or
<code>// NOLINT(rule)</code> to suppress only the incriminated <code>rule</code> category).
{{nowrap|<code>// NOLINT(rule)</code>}} to suppress only the incriminated <code>rule</code> category).


Moreover rules can be fine-grained selected using the options <code>--verbose</code> and <code>--filter</code>.
Moreover rules can be fine-grained selected using the options {{nowrap|<code>--verbose</code>}} and {{nowrap|<code>--filter</code>}}.
Line length rule can be configured with option <code>--linelength</code>
Line length rule can be configured with option {{nowrap|<code>--linelength</code>}}
and file extensions can be configured with <code>--extensions</code> (by default: 'h', 'cpp', 'cc', 'cu' and 'cuh').
and file extensions can be configured with {{nowrap|<code>--extensions</code>}} (by default: 'h', 'cpp', 'cc', 'cu' and 'cuh').
Some options can be stored in a configuration file <code>CPPLINT.cfg</code>.
Some options can be stored in a configuration file {{nowrap|<code>CPPLINT.cfg</code>}}.


cpplint is implemented as a [[Python (programming language)|Python]] script.<ref>{{cite web|title=GIT URL for cpplint.py|author=Google|url=https://github.com/google/styleguide/tree/gh-pages/cpplint}}</ref>
cpplint is implemented as a [[Python (programming language)|Python]] script.<ref>{{cite web|title=GIT URL for cpplint.py|author=Google|url=https://github.com/google/styleguide/tree/gh-pages/cpplint}}</ref>

Revision as of 20:46, 12 March 2019

cpplint or cpplint.py is an open source lint-like tool developed by Google, designed to ensure that C++ code conforms to Google's coding style guides.

Therefore cpplint implements what Google considers best practices in C++ coding. The script cpplint.py reads source code files and flags deviations from the style guide. It also identifies syntax errors. It is rules based, and uses a number of heuristics to identify bad code.[1]

cpplint.py suffers from both false positives and false negatives. False positives can be eliminated by tagging lines with // NOLINT[2] (or // NOLINT(rule) to suppress only the incriminated rule category).

Moreover rules can be fine-grained selected using the options --verbose and --filter. Line length rule can be configured with option --linelength and file extensions can be configured with --extensions (by default: 'h', 'cpp', 'cc', 'cu' and 'cuh'). Some options can be stored in a configuration file CPPLINT.cfg.

cpplint is implemented as a Python script.[3] It is distributed under the 3 clause BSD license.

See also

References

  1. ^ Dutko, Adam M. (2011). The Relational Database: a New Static Analysis Tool? (Master of Science). Cleveland State University. p. 20. ISSN 2572-3480. OCLC 750403495. Archived from the original (PDF) on 18 May 2018. {{cite thesis}}: Unknown parameter |dead-url= ignored (|url-status= suggested) (help)
  2. ^ Weinberger, Benjy. "Google C++ Style Guide, section cpplint".
  3. ^ Google. "GIT URL for cpplint.py". {{cite web}}: |author= has generic name (help)