summaryrefslogtreecommitdiff
path: root/tests/checkers
Commit message (Collapse)AuthorAgeFilesLines
* Migration to pytest from unittest for BaseChecker testsPierre Sassoulas2021-10-271-37/+35
|
* Create a new file for BaseChecker unit testsPierre Sassoulas2021-10-272-61/+69
|
* Add configuration option ``exclude-too-few-public-methods`` (#5191)Mike Fiedler2021-10-261-0/+18
| | | | | | | | | Allow excluding classes based on their ancestors from the ``too-few-public-methods`` checker. Closes #3370 Signed-off-by: Mike Fiedler <miketheman@gmail.com> Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
* Fix use-implicit-booleaness-not-comparison crash (#5176)Jaehoon Hwang2021-10-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix use-implicit-booleaness-not-comparison crash `use-implicit-booleaness-not-comparison` caused a crash due to `target_node` not being an instance of `NodeNG.Name` This fix will allow the checker to have a default handling when it encounters `target_node` other than `Calls`,`Name`, or `Attribute` * Added more comprehensive test for implicit_booealness_checker * Make implicit_booealness_checker to have default `variable_name` * Handle `Calls`,`Name`, or `Attribute` * Fix typing in ImplicitBooleanessChecker.base_classes_of_node * [implicit-booleaness] Add call nodes name in warnings * Use `BaseContainer` to check for empty tuple/list and use `as_string` for `Attribute` and `Name` nodes for message Using `BaseContainer` for checking for empty `tuple` and `list`. In addition, `is_base_container` checks for `FrozenSet` and `Set` as well. * Update test cases with cr concerns * Use `BaseContainer` when checking for empty list or tuple * Update `is_literal_tuple/list` to use `is_base_container` * Use `as_string` when giving out function or variable name for message. * Fix broken baseContainer test * Use safe_infer for inferencing `target_instance` * Swap opreators message * Address CR comments; no more try/catch for infer & Add more test cases * Add more test cases and changed few cases to cover more cases. * Remove `try/catch` from `safe_infer` since `safe_infer` will return `None` when it encounters exceptions. * Comparison from infer to be more explicit; using `None` instead of relying on `bool` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix ``missing-function-docstring`` not checking ``__init__`` (#5147)Daniël van Noord2021-10-171-0/+46
| | | | | | * Fix ``missing-function-docstring`` not checking ``__init__`` * Ignore ``object``
* Fix ``relative-beyond-top-level`` false positiveDaniël van Noord2021-10-171-0/+33
|
* Add a warning ``use-implicit-booleaness-not-comparison`` for comparison with ↵Jaehoon Hwang2021-10-172-13/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | collection literals (#5120) * Create a new checker; use-implicit-booleanness checker where it looks for boolean evaluatiion with collection literals such as `()`, `[]`, or `{}` * Fixed invalid usage of comparison within pylint package This closes #4774 * Ignore tuples when checking for `literal-comparison` Closes #3031 * Merge len_checker with empty_literal checker Moving empty literal checker with len_checker to avoid class without iterators without boolean expressions (false positive on pandas) Reference: https://github.com/PyCQA/pylint/pull/3821/files * Update `len_checker` and its class `LenChecker` to `ComparisonChecker` to reflect better usage after merging between `len_checker` and `empty_literal_checker` and its tests. * Fixed `consider_using_in` and `consider_iterating_dictionary` tests that were failing due to new empty literal checkers. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Rename `len-as-condition` to `use-implicit-booleaness-not-len` (#5132)Jaehoon Hwang2021-10-101-5/+5
| | | | | | | | | | Rename `len-as-condition` to be more general for new checker `use-implicit-booleaness-not-comparison` * Refactor `LenChecker` class -> `ImplicitBooleanessChecker`o * Rename test files/`len_checker.py`/`__init__.py` to reflect new name. * Add `len-as-condition` as `old_names` for `use-implicit-booleaness-not-len` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Add guard helper functions from astroid (#5122)Marc Mueller2021-10-071-14/+73
|
* Rename ``pylint.testutils.TestMessage`` to ``MessageTest`` (#5051)Daniël van Noord2021-09-2013-160/+160
|
* Rename `pylint.testutil.Message` to `pylint.testutil.TestMessage` (#5043)Daniël van Noord2021-09-1813-158/+220
| | | * Rename `Message` to `TestMessage``
* Bump pylint to 2.11.0, update changelogv2.11.0Pierre Sassoulas2021-09-1613-1/+14
|
* Add typing to ``filepath`` (#4980)Daniël van Noord2021-09-161-1/+1
| | | | | | | | | | * Change tests for ``filepath`` changes * Add pylint/typing.py and FileItem NamedTuple * Use NamedTuple more efficiently * Fix errors and tests after adding warning * Add deprecation for future API change in Checker Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix deprecation warning for AssignAttr in tests (#5006)Pierre Sassoulas2021-09-141-9/+6
| | | | | | | * Fix deprecation warning for AssignAttr We should initialize nodes using their constructor Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
* Make ``min-similarity-lines == 0`` stop similarity check (#4970)Daniël van Noord2021-09-071-0/+8
| | | | | | | | * Make ``min-similarity-lines == 0`` stop similarity check This makes it so that setting ``min-similarity-lines`` to zero exit the similarity code checker with a successful exit. This closes #4901 Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
* Add typing with `PyAnnotate` to `./tests` (#4950)Daniël van Noord2021-09-0416-212/+256
| | | | | | * Add mypy_extensions to requirement for ``NoReturn`` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Fix false positive ``superfluous-parens`` for tuplesDaniël van Noord2021-09-011-5/+0
| | | | | | Tuples can be created with inner tuples. This creates double parenthesis which we flagged incorrectly. This closes #4907
* Remove the python3 porting mode from the codebasePierre Sassoulas2021-09-011-1178/+0
| | | | | | It's possible to use the python3 porting checker from an older pylint version. But it's not evolving anymore and was costing resource to maintain.
* Emit a correct invalid-name message when using multi-naming style. (#4924)Yilei "Dolee" Yang2021-08-301-4/+12
| | | | | | | | | | | | | | | | | | | | | | * Emit a correct invalid-name message when using multi-naming style. Previously, given `--function-rgx=(?:(?P<UP>[A-Z]+)|(?P<down>[a-z]+))$` and the code: ``` def FOO(): pass def UPPER(): pass def lower(): pass ``` It would emit a message: ``Function name `lower` doesn't conform to '(?:(?P<UP>[A-Z]+)|(?P<down>[a-z]+))$' pattern [invalid-name]``. The message is misleading as `lower` *does* conform to `(?:(?P<UP>[A-Z]+)|(?P<down>[a-z]+))$`. It's just not the prevalent group "UP". After this commit, the message becomes: ``Function name `lower` doesn't conform to UP group in the '(?:(?P<UP>[A-Z]+)|(?P<down>[a-z]+))$' pattern [invalid-name]`` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Add ``Consider-using-f-string`` checker (#4796)Daniël van Noord2021-08-302-40/+32
| | | | | | | | | | | | | | | | * Add ``consider-using-f-string`` checker This adds a checker for normal strings which are formatted with ``.format()`` or '%'. The message is a convention to nudge users towards using f-strings. This closes #3592 * Update pylint code to use f-strings After adding `consider-using-f-strings` the codebase showed numerous cases of formatting which could be f-strings. This commit changes most of these to become f-strings, or adds ignores. * Apply suggestions from code review Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Bump pylint to 2.10.2-dev0, update changelogAshley Whetter2021-08-201-0/+1
|
* Bump pylint to 2.10.1, update changelogv2.10.1Ashley Whetter2021-08-201-0/+1
|
* Bump pylint to 2.10.0, update changelogv2.10.0Pierre Sassoulas2021-08-204-3/+5
|
* Improve invalid-metaclass error message for InstancesDavid Liu2021-08-191-0/+4
|
* Use alias for astroid.nodes 04 (#4869)Marc Mueller2021-08-191-2/+3
| | | | | | | | | * Use alias for astroid nodes 04 * Resolve name conflicts * Apply suggestions from code review Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* [duplicate-code] Parse functions and class methods recursively when ↵Maksym Humetskyi2021-08-171-0/+62
| | | | | gathering signature lines (#4858) * [duplicate-code] Parse functions and class methods recursively when gathering signature lines
* [duplicate-code] Ignore decorators lines by similarities checker when ignore ↵Maksym Humetskyi2021-08-141-4/+14
| | | | | | | | | | | | signatures flag enabled (#4840) * [duplicate-code] Ignore decorators lines by similarities checker when ignore signatures flag enabled * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Maksym Humetskyi <mhumets@softserveinc.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix false positives for ``superfluous-parens`` (#4784)Daniël van Noord2021-08-031-16/+19
| | | | | | | | | | | | | | * Split functional tests for ``superfluous-parents`` * Fix false positives for superfluous-parens This fixes the false positives identified in #2818, #3249, #3608 & #4346 All false positives reported fell under keywords before walrus operator or if-keyword within generators/comprehension. This closes #2818, closes #3429, closes #3608, closes #4346 * Move the superfluous functional tests to functional/s/super Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add ignored-parents option to design checker (#4758)Rebecca Turner2021-07-281-0/+41
| | | | | | | | | | | * Add ignored-parents option to design checker This allows users to specify classes to ignore while counting parent classes. Partially closes #3057 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Performance improvment of the Similarity checker (#4565)hippo912021-07-281-51/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Adds execution time measurements * Remove @profile decorator * Changes the whole algorithm. The old one, while being very readable, is a performance bottleneck especially when comparing two big files. Let's try a more efficient one... * Use a copy of SuccessiveLinesLimits in the all_couples collection in order to avoid modification of the same object when removing successives common lines (in remove_successive method). * Remove old algorithm (dead code now) * Creates the LineSpecifs type, to be clearer when manipulating stripped lines. * Adds type hint in the stripped_lines function signature. Modifies docstring for the same function * LineSetStartCouple is now a classic class (no more NamedTuple). It allows to define __add__ dunder method to make operations clearer * Adds __repr__ method to SuccessiveLinesLimits class. Also update the docstring * Modifies the way the LinesChunk hash is computed. If the line is not empty or is empty but corresponds to a docstring then the hash is the classical one. Otherwise the hash is randomized in order to be sure that two empty lines corresponding to import line are not considered equal * Empty lines that were comments before being stripped are considered as equal * Rework the help message do distinguish the options * Adds a full line of comments in the test and adapts the expected results * ignore-docstrings by default is True and so all docstrings (differents or identicals) are considered identicals * In case of multiprocessing reports options * Simplifies the algoriothm and clarifies the use of the options. For now if something is ignored (docstrings, comments, signature, imports) then it is removed from stripped lines collection. No need of the LineType anymore. The drawback is that 2 chunks of lines in both file may have been detected as similar (which is correct) but have different number of lines because, for example, some comments are inserted and comments habe ignored. * The CplSuccessiveLinesLimits is no more a NamedTuple because we added the effective_cm_lines_nb member which has to be mutable. It holds the number of "true" common lines between both files (i.e the number of common lines in both stripped lines collection) * check_sim function is renamed filter_noncode_lines and check the similarities on the stripped lines collection (and no more the real lines collection). Adds the computation of the effective number of common lines (i.e the number of "true" common stripped lines) * Adapts legacy code so that the effective number of common lines is printed (the number of common lines in both stripped lines collection) and the corresponding component of the first file is printed too. * Updates the expected result so that they contain the effective common lines number * Stripped lines are purged from all that is ignored (by default comments and docstrings). Adapts the expected result in consquence * By default comment and docstrings are excluded from the comparison * Print also the ending line number in the report * Adapts the expected results to take into account the ending line number * Takes into account Pierre-Sassoulas remarks * Takes into accound the remarks of cdce8p * The parameters of the SImilarChecker are read from configuration also in the __init__ method Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Add unspecified-encoding checker #3826 (#4753)Daniël van Noord2021-07-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add unspecified-encoding checker #3826 This adds an unspecified-encoding checker that adds a warning whenever open() is called without an explicit encoding argument. This closes #3826 * Update tests to conform to unspecified-encoding With addition of the unspecified-encoding checker calls of open() need an encoding argument. Where necessary this argument has been added, or the message has been disabled. This also includes small linting changes to a small number of tests. Their test-data has been updated to reflect new line numbers. * Update scripts to conform to unspecified-encoding With addition of the unspecified-encoding checker calls of open() need an encoding argument. Where necessary this argument has been added. * Update pylint to conform to unspecified-encoding With addition of the unspecified-encoding checker calls of open() need an encoding argument. Where necessary this argument has been added. Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
* Bump pylint to 2.9.4, update changelogv2.9.4Pierre Sassoulas2021-07-201-0/+1
|
* Use absolute import qualified module name for deprecated module check (#4678)Matus Valo2021-07-061-1/+1
| | | | * Use absolute import qualified module name for deprecated module check * Improved docstring of get_import_name
* [duplicate-code] Fix ignored empty functions by similarities checker with ↵Maksym Humetskyi2021-07-051-0/+40
| | | | | ignore-signatures option enabled (#4669) Co-authored-by: Maksym Humetskyi <mhumets@softserveinc.com>
* Bump pylint to 2.9.3, update changelogv2.9.3Pierre Sassoulas2021-07-0114-1/+14
|
* [duplicate-code] Remove trailing whitespaces in similarity reportPierre Sassoulas2021-07-011-1/+1
| | | | And fix tests/checkers/unittest_similar.py that required to have some
* [duplicate-code] Fix crash when analysing empty function with docstringPierre Sassoulas2021-07-011-5/+8
| | | | Closes #4648
* Fix copyright links (#4647)Marc Mueller2021-07-0116-16/+16
| | | | * Fix link in license header * Update link to astroid bump_changelog
* Bump pylint to 2.9.0, update changelog, add python 3.10 to package metav2.9.0Pierre Sassoulas2021-06-291-0/+1
|
* Fix a syntax error in unittest_deprecated.py test codePierre Sassoulas2021-06-291-1/+1
|
* Added support for deprecated method aliasMatus Valo2021-06-291-0/+25
|
* VariableChecker now accounts for attribute lookups in type comments (#4604)Sergei Lebedev2021-06-271-0/+20
| | | | | | | | | | | * VariableChecker now accounts for attribute lookups in type comments Prior to this commit VariableChecker did not recurse into attribute lookups in type comments. This lead to false positive unused-import messages in e.g. import collections d = ... # type: collections.OrderedDict Fixes #4603
* Bump pylint to 2.9.0-dev1, update changelogPierre Sassoulas2021-06-173-0/+3
|
* Fix existing codeMarc Mueller2021-06-101-2/+2
|
* Added deprecated decorators check (#4513)Matus Valo2021-05-271-0/+53
| | | | | | | * Added deprecated decorators check * Updated Changelog and whatsnew Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
* Implemented ``unused-private-member`` checker (#4504)yushao22021-05-251-0/+24
|
* Add ignore_signatures to similarity checker (#4474)Aditya Gupta2021-05-171-0/+41
| | | | | | * Add ignore_signatures to similarity checker Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add Deprecated Class unittests (#4448)Matus Valo2021-05-081-0/+55
| | | * Add Deprecated Class unittests
* Add support for checking deprecated class arguments. (#4425)Matus Valo2021-05-011-0/+24
| | | * Add deprecated class arguments
* Update copyrite noticev2.8.2Pierre Sassoulas2021-04-261-0/+1
|