Skip to content

Commit

Permalink
chore: bump CPPLINT to 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed May 17, 2023
1 parent 59aafa3 commit 84d362d
Show file tree
Hide file tree
Showing 11 changed files with 460 additions and 18 deletions.
127 changes: 127 additions & 0 deletions CPPLINT/.gitignore
@@ -0,0 +1,127 @@
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

### Python Patch ###
.venv/

### Python.VirtualEnv Stack ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json
8 changes: 8 additions & 0 deletions CPPLINT/changelog.rst
@@ -1,6 +1,14 @@
Changelog
=========

1.6.1 (2022-08-20)
-----

* Fix #195 Fix post increment/decrement operator causing a false positive.
* Fix #202 .hh files should not be considered sytem headers
* Fix #207 Python2 incompatibility for loading CPPLINT.cfg file
* Fix #184 NOLINT(clang-analyzer) comments should not cause warnings

1.6.0 (2022-02-19)
-----

Expand Down
19 changes: 16 additions & 3 deletions CPPLINT/cpplint.py
Expand Up @@ -64,9 +64,10 @@
# if empty, use defaults
_valid_extensions = set([])

__VERSION__ = '1.6.0'
__VERSION__ = '1.6.1'

try:
# -- pylint: disable=used-before-assignment
xrange # Python 2
except NameError:
# -- pylint: disable=redefined-builtin
Expand Down Expand Up @@ -373,6 +374,12 @@
'readability/function',
]

# These prefixes for categories should be ignored since they relate to other
# tools which also use the NOLINT syntax, e.g. clang-tidy.
_OTHER_NOLINT_CATEGORY_PREFIXES = [
'clang-analyzer',
]

# The default state of the category filter. This is overridden by the --filter=
# flag. By default all errors are on, so only add here categories that should be
# off by default (i.e., categories that must be enabled by the --filter= flags).
Expand Down Expand Up @@ -877,12 +884,14 @@
_include_order = "default"

try:
# -- pylint: disable=used-before-assignment
unicode
except NameError:
# -- pylint: disable=redefined-builtin
basestring = unicode = str

try:
# -- pylint: disable=used-before-assignment
long
except NameError:
# -- pylint: disable=redefined-builtin
Expand Down Expand Up @@ -984,6 +993,9 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error):
category = category[1:-1]
if category in _ERROR_CATEGORIES:
_error_suppressions.setdefault(category, set()).add(suppressed_line)
elif any(c for c in _OTHER_NOLINT_CATEGORY_PREFIXES if category.startswith(c)):
# Ignore any categories from other tools.
pass
elif category not in _LEGACY_ERROR_CATEGORIES:
error(filename, linenum, 'readability/nolint', 5,
'Unknown NOLINT error category: %s' % category)
Expand Down Expand Up @@ -5012,7 +5024,8 @@ def _ClassifyInclude(fileinfo, include, used_angle_brackets, include_order="defa
or Search(r'(?:%s)\/.*\.h' % "|".join(C_STANDARD_HEADER_FOLDERS), include))

# Headers with C++ extensions shouldn't be considered C system headers
is_system = used_angle_brackets and not os.path.splitext(include)[1] in ['.hpp', '.hxx', '.h++']
include_ext = os.path.splitext(include)[1]
is_system = used_angle_brackets and not include_ext in ['.hh', '.hpp', '.hxx', '.h++']

if is_system:
if is_cpp_header:
Expand Down Expand Up @@ -6532,7 +6545,7 @@ def ProcessConfigOverrides(filename):
continue

try:
with open(cfg_file, encoding='utf-8') as file_handle:
with codecs.open(cfg_file, 'r', 'utf8', 'replace') as file_handle:
for line in file_handle:
line, _, _ = line.partition('#') # Remove comments.
if not line.strip():
Expand Down
3 changes: 3 additions & 0 deletions CPPLINT/cpplint_clitest.py
Expand Up @@ -166,6 +166,9 @@ def testVlcSample(self):
def testSillySample(self):
self.checkAllInFolder('./samples/silly-sample', 4)

def testCfgFileSample(self):
self.checkAllInFolder('./samples/cfg-file', 1)

def testBoostSample(self):
self.checkAllInFolder('./samples/boost-sample', 4)

Expand Down
3 changes: 3 additions & 0 deletions CPPLINT/samples/cfg-file/CPPLINT.cfg
@@ -0,0 +1,3 @@
set noparent
filter=-whitespace,-build/include_what_you_use
linelength=80
26 changes: 26 additions & 0 deletions CPPLINT/samples/cfg-file/simple.def
@@ -0,0 +1,26 @@
src/*.cpp
1
3
Done processing src/sillycode.cpp
Total errors found: 19

src/sillycode.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
src/sillycode.cpp:3: Found C system header after C++ system header. Should be: sillycode.h, c system, c++ system, other. [build/include_order] [4]
src/sillycode.cpp:14: Is this a non-const reference? If so, make const or use a pointer: vector<string>& v [runtime/references] [2]
src/sillycode.cpp:40: If/else bodies with multiple statements require braces [readability/braces] [4]
src/sillycode.cpp:66: Single-parameter constructors should be marked explicit. [runtime/explicit] [5]
src/sillycode.cpp:76: Single-parameter constructors should be marked explicit. [runtime/explicit] [5]
src/sillycode.cpp:85: Constructors callable with one argument should be marked explicit. [runtime/explicit] [5]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:118: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& a [runtime/references] [2]
src/sillycode.cpp:123: Is this a non-const reference? If so, make const or use a pointer: N::X& b [runtime/references] [2]
src/sillycode.cpp:171: Do not use variable-length arrays. Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size. [runtime/arrays] [1]
src/sillycode.cpp:178: Static/global string variables are not permitted. [runtime/string] [4]
src/sillycode.cpp:199: If an else has a brace on one side, it should have it on both [readability/braces] [5]
src/sillycode.cpp:202: If an else has a brace on one side, it should have it on both [readability/braces] [5]
src/sillycode.cpp:208: Static/global string variables are not permitted. [runtime/string] [4]
src/sillycode.cpp:227: Static/global string variables are not permitted. [runtime/string] [4]
src/sillycode.cpp:228: Using C-style cast. Use reinterpret_cast<double*>(...) instead [readability/casting] [4]
src/sillycode.cpp:243: Using C-style cast. Use reinterpret_cast<derived2*>(...) instead [readability/casting] [4]

0 comments on commit 84d362d

Please sign in to comment.