From 872eca033caf5cd96c2707600b26ec5e47fece23 Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Sun, 29 Aug 2021 20:48:19 +0500 Subject: [PATCH 1/6] Added some new words --- whitelist.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/whitelist.txt b/whitelist.txt index e6557afa..3d259ae0 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -236,3 +236,17 @@ xpath yanchor yaxes yaxis +stdlib +maxsplit +xrange +unichr +maxint +execfile +setslice +rdiv +idiv +getslice +delslice +redeclared +xreadlines +metaclass From 9e20e141b566e4c4f989dd71131b4558516bbca9 Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Sun, 29 Aug 2021 20:48:28 +0500 Subject: [PATCH 2/6] Added W0511 --- src/python/review/inspectors/pylint/pylintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/review/inspectors/pylint/pylintrc b/src/python/review/inspectors/pylint/pylintrc index 357ba058..7ce63a81 100644 --- a/src/python/review/inspectors/pylint/pylintrc +++ b/src/python/review/inspectors/pylint/pylintrc @@ -166,6 +166,7 @@ disable=invalid-name, no-else-continue, W0614, W0622, + W0511, # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option From 38e6bb0038c6019dbb100a090d33bf1c0fdb8954 Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Sun, 29 Aug 2021 20:48:39 +0500 Subject: [PATCH 3/6] Added WPS428 --- src/python/review/inspectors/flake8/issue_types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/review/inspectors/flake8/issue_types.py b/src/python/review/inspectors/flake8/issue_types.py index b1074b52..a57031ba 100644 --- a/src/python/review/inspectors/flake8/issue_types.py +++ b/src/python/review/inspectors/flake8/issue_types.py @@ -73,6 +73,7 @@ 'WPS419': IssueType.ERROR_PRONE, # Forbid multiple returning paths with try / except case. 'WPS424': IssueType.ERROR_PRONE, # Forbid BaseException exception. 'WPS426': IssueType.ERROR_PRONE, # Forbid lambda inside loops. + 'WPS428': IssueType.ERROR_PRONE, # Forbid statements that do nothing. 'WPS432': IssueType.INFO, # Forbid magic numbers. 'WPS433': IssueType.CODE_STYLE, # Forbid imports nested in functions. 'WPS439': IssueType.ERROR_PRONE, # Forbid Unicode escape sequences in binary strings. From 04f782b9814cb26b0a00e3b274174c24878cf6bd Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Sun, 29 Aug 2021 20:49:06 +0500 Subject: [PATCH 4/6] Added many exceptions --- .../review/inspectors/pylint/issue_types.py | 156 +++++++++++++++--- 1 file changed, 137 insertions(+), 19 deletions(-) diff --git a/src/python/review/inspectors/pylint/issue_types.py b/src/python/review/inspectors/pylint/issue_types.py index 048f0c45..c1cc1924 100644 --- a/src/python/review/inspectors/pylint/issue_types.py +++ b/src/python/review/inspectors/pylint/issue_types.py @@ -2,30 +2,148 @@ from src.python.review.inspectors.issue import IssueType +CODE_TO_ISSUE_TYPE: Dict[str, IssueType] = { + # Basic checker + 'W0129': IssueType.ERROR_PRONE, # Assert statement has a string literal as its first argument + 'W0127': IssueType.ERROR_PRONE, # Assigning the same variable to itself + 'W0143': IssueType.ERROR_PRONE, # Comparing against a callable + 'W0102': IssueType.ERROR_PRONE, # Dangerous default value as argument + 'W0109': IssueType.ERROR_PRONE, # Duplicate key in dictionary + 'W0106': IssueType.ERROR_PRONE, # Expression is assigned to nothing + 'W0128': IssueType.ERROR_PRONE, # Redeclared variable in assignment + 'W0104': IssueType.ERROR_PRONE, # Statement seems to have no effect + 'W0105': IssueType.ERROR_PRONE, # String statement has no effect + 'W0107': IssueType.BEST_PRACTICES, # Unnecessary pass statement + 'W0101': IssueType.ERROR_PRONE, # Unreachable code + 'W0125': IssueType.ERROR_PRONE, # Using a conditional statement with a constant value + 'W0126': IssueType.ERROR_PRONE, # Using a conditional statement with wrong function due to missing parentheses + 'R0124': IssueType.ERROR_PRONE, # Redundant comparison + 'C0121': IssueType.BEST_PRACTICES, # Expression is compared to singleton values like True, False or None + 'C0112': IssueType.BEST_PRACTICES, # Empty docstring + 'C0123': IssueType.BEST_PRACTICES, # Use isinstance() rather than type() for a type check + + # Classes checker + 'E0213': IssueType.CODE_STYLE, # Method should have "self" as first argument + 'W0221': IssueType.ERROR_PRONE, # Method has diff. number of args than in the interface or in an overridden method + 'W0237': IssueType.ERROR_PRONE, # Method parameter has diff. name than in the interface or in an overridden method + 'W0223': IssueType.ERROR_PRONE, # Method is abstract in class but is not overridden + 'W0236': IssueType.ERROR_PRONE, # Method was overridden in a way that does not match its base class + 'W0222': IssueType.ERROR_PRONE, # Signature differs from method + 'W0231': IssueType.ERROR_PRONE, # __init__ method from base class is not called + 'C0205': IssueType.ERROR_PRONE, # Class __slots__ should be a non-string iterable + + # Design checker + 'R0901': IssueType.COMPLEXITY, # too-many-ancestors + 'R0913': IssueType.COMPLEXITY, # too-many-arguments + 'R0916': IssueType.COMPLEXITY, # too-many-boolean-expressions + 'R0912': IssueType.COMPLEXITY, # too-many-branches + 'R0902': IssueType.COMPLEXITY, # too-many-instance-attributes + 'R0914': IssueType.COMPLEXITY, # too-many-locals + 'R0904': IssueType.COMPLEXITY, # too-many-public-methods + 'R0911': IssueType.COMPLEXITY, # too-many-return-statements + 'R0915': IssueType.COMPLEXITY, # too-many-statements + + # Exceptions checker + 'W0705': IssueType.ERROR_PRONE, # Catching previously caught exception type + 'W0706': IssueType.ERROR_PRONE, # The except handler raises immediately + + # Format checker + 'W0311': IssueType.CODE_STYLE, # Bad indentation + 'W0301': IssueType.CODE_STYLE, # Unnecessary semicolon + 'C0302': IssueType.COMPLEXITY, # Too many lines in module + + # Imports checker + 'R0401': IssueType.ERROR_PRONE, # Cyclic import + 'C0415': IssueType.BEST_PRACTICES, # Import outside toplevel + + # Python3 checker + 'W1659': IssueType.ERROR_PRONE, # Accessing a removed xreadlines attribute + 'W1623': IssueType.ERROR_PRONE, # Assigning to a class's __metaclass__ attribute + 'W1622': IssueType.ERROR_PRONE, # Called a next() method on an object + 'W1620': IssueType.ERROR_PRONE, # Calling a dict.iter*() method + 'W1621': IssueType.ERROR_PRONE, # Calling a dict.view*() method + 'W1645': IssueType.ERROR_PRONE, # Exception.message removed in Python 3 + 'W1641': IssueType.ERROR_PRONE, # Implementing __eq__ without also implementing __hash__ + 'W1624': IssueType.ERROR_PRONE, # Indexing exceptions will not work on Python 3 + 'W1648': IssueType.ERROR_PRONE, # Module moved in Python 3 + 'W1625': IssueType.ERROR_PRONE, # Raising a string exception + 'W1611': IssueType.ERROR_PRONE, # StandardError built-in referenced + 'W1662': IssueType.ERROR_PRONE, # Using a variable that was bound inside a comprehension + 'W1661': IssueType.ERROR_PRONE, # Using an exception object that was bound by an except handler + 'W1640': IssueType.ERROR_PRONE, # Using the cmp argument for list.sort / sorted + 'W1630': IssueType.ERROR_PRONE, # __cmp__ method defined + 'W1614': IssueType.ERROR_PRONE, # __coerce__ method defined + 'W1615': IssueType.ERROR_PRONE, # __delslice__ method defined + 'W1642': IssueType.ERROR_PRONE, # __div__ method defined + 'W1616': IssueType.ERROR_PRONE, # __getslice__ method defined + 'W1628': IssueType.ERROR_PRONE, # __hex__ method defined + 'W1643': IssueType.ERROR_PRONE, # __idiv__ method defined + 'W1629': IssueType.ERROR_PRONE, # __nonzero__ method defined + 'W1627': IssueType.ERROR_PRONE, # __oct__ method defined + 'W1644': IssueType.ERROR_PRONE, # __rdiv__ method defined + 'W1617': IssueType.ERROR_PRONE, # __setslice__ method defined + 'W1601': IssueType.ERROR_PRONE, # apply built-in referenced + 'W1602': IssueType.ERROR_PRONE, # basestring built-in referenced + 'W1603': IssueType.ERROR_PRONE, # buffer built-in referenced + 'W1604': IssueType.ERROR_PRONE, # cmp built-in referenced + 'W1605': IssueType.ERROR_PRONE, # coerce built-in referenced + 'W1619': IssueType.ERROR_PRONE, # division w/o __future__ statement + 'W1606': IssueType.ERROR_PRONE, # execfile built-in referenced + 'W1607': IssueType.ERROR_PRONE, # file built-in referenced + 'W1618': IssueType.ERROR_PRONE, # import missing `from __future__ import absolute_import` + 'W1632': IssueType.ERROR_PRONE, # input built-in referenced + 'W1634': IssueType.ERROR_PRONE, # intern built-in referenced + 'W1608': IssueType.ERROR_PRONE, # long built-in referenced + 'W1653': IssueType.ERROR_PRONE, # next method defined + 'W1609': IssueType.ERROR_PRONE, # raw_input built-in referenced + 'W1610': IssueType.ERROR_PRONE, # reduce built-in referenced + 'W1626': IssueType.ERROR_PRONE, # reload built-in referenced + 'W1633': IssueType.ERROR_PRONE, # round built-in referenced + 'W1647': IssueType.ERROR_PRONE, # sys.maxint removed + 'W1635': IssueType.ERROR_PRONE, # unichr built-in referenced + 'W1612': IssueType.ERROR_PRONE, # unicode built-in referenced + 'W1613': IssueType.ERROR_PRONE, # xrange built-in referenced + + # Refactoring checker + 'R1702': IssueType.COMPLEXITY, # Too many nested blocks + 'C0113': IssueType.BEST_PRACTICES, # Boolean expression contains an unneeded negation + 'C0201': IssueType.BEST_PRACTICES, # Consider iterating the dictionary directly instead of calling .keys() + 'C0206': IssueType.BEST_PRACTICES, # Consider iterating with .items() + 'C0200': IssueType.BEST_PRACTICES, # Consider using enumerate instead of iterating with range and len + 'C1801': IssueType.BEST_PRACTICES, # Do not use `len(foo)` without comparison to determine if a 'foo' is empty + 'C0207': IssueType.BEST_PRACTICES, # use-maxsplit-arg + 'C0208': IssueType.BEST_PRACTICES, # Use a sequence type when iterating over values + + # Stdlib checker + 'W1501': IssueType.ERROR_PRONE, # bad-open-mode + + # String checker + 'W1308': IssueType.ERROR_PRONE, # Duplicate string formatting argument, consider passing as named argument + 'W1305': IssueType.ERROR_PRONE, # Format string contains both automatic numbering and manual specification + 'W1300': IssueType.ERROR_PRONE, # Format string dictionary key should be a string + 'W1302': IssueType.ERROR_PRONE, # Invalid format string + 'W1306': IssueType.ERROR_PRONE, # Missing format attribute in format specifier + 'W1303': IssueType.ERROR_PRONE, # Missing keyword argument for format string + 'W1304': IssueType.ERROR_PRONE, # Unused format argument + 'W1301': IssueType.ERROR_PRONE, # Unused key in format string dictionary + 'W1309': IssueType.ERROR_PRONE, # Using an f-string that does not have any interpolated variables + 'W1310': IssueType.ERROR_PRONE, # Using formatting for a string that does not have any interpolated variables + 'W1307': IssueType.ERROR_PRONE, # Using invalid lookup key in format specifier + + # Variables check + 'W0632': IssueType.ERROR_PRONE, # Possible unbalanced tuple unpacking with sequence + 'W0622': IssueType.ERROR_PRONE, # Redefining built-in + 'W0631': IssueType.ERROR_PRONE, # Using possibly undefined loop variable + + # Other + 'W0312': IssueType.CODE_STYLE, # mixed indentation +} + # C convention related checks # R refactoring related checks # W warnings for stylistic issues, or minor programming issues # E errors, for probable bugs in the code -CODE_TO_ISSUE_TYPE: Dict[str, IssueType] = { - 'C0200': IssueType.BEST_PRACTICES, # consider using enumerate - 'C0113': IssueType.BEST_PRACTICES, - 'C0415': IssueType.BEST_PRACTICES, # import-outside-toplevel - 'W0101': IssueType.ERROR_PRONE, # unreachable code - 'W0102': IssueType.ERROR_PRONE, # dangerous default value - 'W0104': IssueType.ERROR_PRONE, # statement doesn't have any effect - 'W0109': IssueType.ERROR_PRONE, # duplicate key in dictionary - 'W0221': IssueType.ERROR_PRONE, # arguments number differs from method - 'W0222': IssueType.ERROR_PRONE, # different signature - 'W0223': IssueType.ERROR_PRONE, # abstract method is not overridden - 'W0231': IssueType.ERROR_PRONE, # super init not called - 'W0311': IssueType.CODE_STYLE, # bad indentation - 'W0312': IssueType.CODE_STYLE, # mixed indentation - 'W0631': IssueType.ERROR_PRONE, # using an undefined loop variable - 'W0622': IssueType.ERROR_PRONE, # redefining built-in - 'W1648': IssueType.ERROR_PRONE, # a module is no longer exists -} - CATEGORY_TO_ISSUE_TYPE: Dict[str, IssueType] = { 'C': IssueType.CODE_STYLE, 'R': IssueType.BEST_PRACTICES, From ff484eb4960b4b79cf15e56efd04aa9e878cbc6b Mon Sep 17 00:00:00 2001 From: GirZ0n Date: Sun, 29 Aug 2021 15:50:37 +0000 Subject: [PATCH 5/6] Sort whitelists (Github Actions) --- whitelist.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/whitelist.txt b/whitelist.txt index 3d259ae0..0fc7798b 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -61,6 +61,7 @@ dataloader dataset datasets dedent +delslice desc detekt df @@ -80,6 +81,7 @@ eslint etree eval exc +execfile expr exprs f1 @@ -93,12 +95,14 @@ func getitem getline getroot +getslice getuid gradle groupby hashtable hline hyperstyle +idiv idx ignorecase iloc @@ -133,9 +137,12 @@ loc logits maintainabilities matcher +maxint +maxsplit mccabe mcs measurer +metaclass min minsize misrefactored @@ -179,13 +186,16 @@ pyast pylint qodana qodanadataset +rdiv readouterr +redeclared reindex removeprefix rfind rmdir runtime setdefault +setslice showline sigmoid singleline @@ -196,6 +206,7 @@ spotbugs springlint sqrt src +stdlib stmts subdir subdirs @@ -209,6 +220,7 @@ tmp tokenizer toplevel uncommented +unichr uniformtext uniq unique @@ -233,20 +245,8 @@ xaxes xaxis xlsx xpath +xrange +xreadlines yanchor yaxes yaxis -stdlib -maxsplit -xrange -unichr -maxint -execfile -setslice -rdiv -idiv -getslice -delslice -redeclared -xreadlines -metaclass From 45a584eceedaf49cb810688f967a2a03c04cb3cf Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Mon, 30 Aug 2021 13:25:32 +0500 Subject: [PATCH 6/6] Comments fix --- .../review/inspectors/pylint/issue_types.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/python/review/inspectors/pylint/issue_types.py b/src/python/review/inspectors/pylint/issue_types.py index c1cc1924..1a9ab612 100644 --- a/src/python/review/inspectors/pylint/issue_types.py +++ b/src/python/review/inspectors/pylint/issue_types.py @@ -33,15 +33,15 @@ 'C0205': IssueType.ERROR_PRONE, # Class __slots__ should be a non-string iterable # Design checker - 'R0901': IssueType.COMPLEXITY, # too-many-ancestors - 'R0913': IssueType.COMPLEXITY, # too-many-arguments - 'R0916': IssueType.COMPLEXITY, # too-many-boolean-expressions - 'R0912': IssueType.COMPLEXITY, # too-many-branches - 'R0902': IssueType.COMPLEXITY, # too-many-instance-attributes - 'R0914': IssueType.COMPLEXITY, # too-many-locals - 'R0904': IssueType.COMPLEXITY, # too-many-public-methods - 'R0911': IssueType.COMPLEXITY, # too-many-return-statements - 'R0915': IssueType.COMPLEXITY, # too-many-statements + 'R0901': IssueType.COMPLEXITY, # Too many ancestors + 'R0913': IssueType.COMPLEXITY, # Too many arguments + 'R0916': IssueType.COMPLEXITY, # Too many boolean expressions + 'R0912': IssueType.COMPLEXITY, # Too many branches + 'R0902': IssueType.COMPLEXITY, # Too many instance attributes + 'R0914': IssueType.COMPLEXITY, # Too many locals + 'R0904': IssueType.COMPLEXITY, # Too many public methods + 'R0911': IssueType.COMPLEXITY, # Too many return statements + 'R0915': IssueType.COMPLEXITY, # Too many statements # Exceptions checker 'W0705': IssueType.ERROR_PRONE, # Catching previously caught exception type