Commit graph

143 commits

Author SHA1 Message Date
Ian Cordasco
2baaf00e83
Further refine our logic handling selection
There was a *very* subtle bug in how we handle blanket select statements
with error codes that are in our DEFAULT_IGNORE. In the specific case,
users were specifying ``--select E`` and E126 was not being properly
reported. This unveiled further logic bugs as we refined this.

Closes #318
2017-05-27 19:22:38 -05:00
Ian Cordasco
a42299d008
Support spaces as error/ignore code separators
Closes #329
2017-05-25 20:07:48 -05:00
Ian Cordasco
25566468a2
Filter out empty ignore/select codes
When we parse out our comma separated lists, we should ignore empty
strings to avoid them breaking users' expectations.

Closes #330
2017-05-20 20:26:27 -05:00
Jon Dufresne
541bac6a82 Clean up some uses of set, list, and dict
* Use set literals instead of set([...])
* Avoid list(sorted(...)) as sorted returns a list
* Replace dict() with dict literal
2017-05-13 07:14:41 -07:00
Ian Cordasco
c62de6acc3
Make formatting plugin logic easier to test
By splitting out the logic to retrieve and return the formatting class
for an application, we can test it more easily and increase our test
coverage of this critical logic.

Refs #320
2017-05-13 08:00:43 -05:00
Ian Cordasco
15ddc3aa2e
Handle missing default formatter
In the event that we cannot load our plugins, we shouldn't raise a
cryptic KeyError from our formatter.

Closes #320
2017-05-13 06:52:08 -05:00
Ian Cordasco
32f4b65b6b
Fix docstring violations 2017-05-12 20:34:15 -05:00
Anthony Sottile
0559e0b43c Don't apply excludes greedily to subdirs 2017-03-16 13:44:33 -07:00
Ian Cordasco
733a4f053b Merge branch 'bug/306' into 'master'
Modify stdin retriever to detect coding pragma

Closes #306

See merge request !177
2017-03-01 12:40:31 +00:00
Ian Cordasco
879d3fc0d7
Modify stdin retriever to detect coding pragma
When we read in a file on Python 3, we use the tokenize module to detect
the coding pragma at the top of the file. We then use that to decode the
rest of the file. However, when we were receiving stdin, we would not do
that.

This updates ``stdin_get_value`` in a backwards compatible way to check
for that coding pragma and then fall back to UTF-8 if necessary.

Closes #306
2017-02-20 07:38:28 -06:00
Ian Cordasco
a98ec12bc6 Merge branch 'legacy_api_custom_formatter' into 'master'
Make init_report in legacy_api correctly replace all references to old formatter.

See merge request !161
2017-02-08 12:40:43 +00:00
Ian Cordasco
218a0b6980
Release v3.3.0
Closes #300
2017-02-06 13:46:51 -06:00
Ian Cordasco
49fcbf468d
Do not run git-hook checks when there are no files
Apparently there are some cases where the git hook will not find files
to run the checks against (e.g., when amending a commit message). In
those cases, it's best not to attempt to run any checks and to allow the
hook to exit successfully.

Closes #303
2017-01-27 15:57:23 -06:00
Ian Cordasco
7ca05a9ca1
Avoid calling rstrip on None
When we receive a SyntaxError, it is not guaranteed to have a token that
includes the physical line causing the issue. If it does not, we now
will avoid trying to determine the number of rows and columns that are
actually there and default to what the error tells us.

Closes #279
2017-01-27 15:22:49 -06:00
Ian Cordasco
9f8dfd924a
Return similarly named, non-submodule modules
In our setuptools integration command, we were attempting to avoid
checking each submodule in the packages list. This was done without
recognizing that two modules may start with the same prefix, e.g.,

- foo
- foo_bar
- foo_biz

In this case, we only ever checked ``foo``. By appending a '.' to the
end of each package name, we avoid this since we only care about
deduplicating submodules, e.g.,

- foo
- foo.sub
- foo.sub.sub

Closes #295
2017-01-22 15:00:48 -06:00
Raphael Das Gupta
f0f2ea7f4e
Force --version to be reproducible
By ordering the plugins, --version becomes reproducible so that it
continuously prints the same output (provided the plugins have not
changed).

Closes #297
2017-01-21 13:59:49 -06:00
Andrew Drake
b806d122d3 Correct "systema" typo in usage documentation. 2017-01-17 14:58:50 -08:00
Ian Cordasco
a0280240fc
Merge branch 'setuptools-exit' of scop/flake8 2017-01-14 10:33:32 -06:00
Ian Cordasco
d6b1baf8af
Display the local paths from the git hook
Instead of displaying the path to the temporary directory, as we always
have, it's been requested that we instead display the path to the file
that was copied to the temporary directory.

Closes #244
2016-12-20 19:15:18 -06:00
Ian Cordasco
5248cf3c2d
Enable users who want to track all files processed
This adds two new methods to the BaseFormatter class:

- beginning
- finished

These will indicate when Flake8 begins and finishes processing a file.

Closes #251
2016-12-20 19:08:11 -06:00
Ian Cordasco
9b8f038a97
Tidy up last few bits for performance improvement 2016-12-20 18:29:10 -06:00
Philip Witty
55fbdec61c Recreate file_checker_manager since it has references to old style_guide/formatter. 2016-12-15 11:30:10 +00:00
Ville Skyttä
2bc78e62bc Cause system exit only for non-zero exit statuses in setuptools command
See https://github.com/pypa/setuptools/issues/850#issuecomment-265445007
2016-12-08 18:13:03 +02:00
Anthony Sottile
109f5f8888 Simplify and speed up multiprocessing 2016-11-29 09:00:33 -08:00
Lukasz Langa
2f1338c342 Assign missing codes to PyFlakes messages
Some PyFlakes messages weren't covered by unique messages, making them
impossible to select/ignore. This is now fixed.

To ensure we don't regress in the future, a test has been added that fails if
there's any uncovered messages.
2016-11-28 10:34:38 -08:00
Ian Cordasco
e4582ef4e7
Only force files to be included when run from CLI
Previously we added support so users can do:

    $ flake8 bin/executable

But this broke the fact that git hooks shouldn't check things like
reStructuredText doc files. This commit restores that functionality but
will cause bin/executable to be ignored in the git hook. This seems fair
since folks can amend their filename patterns to include it explicitly.

Closes #268
2016-11-23 16:36:26 -06:00
Ian Cordasco
a52aedc0a0
Prepare for 3.3.0 development 2016-11-21 17:46:09 -06:00
Ian Cordasco
a981fe34ed
Update release notes and version string for 3.2.1 2016-11-19 19:34:33 -06:00
Ian Cordasco
ae9e832cc1 Merge branch 'bug/259' into 'master'
Handle SyntaxErrors in a slightly smarter way

SyntaxErrors are strange and mystical beasts. On top of the problems we
encountered previously in GitLab#237, it's now apparent that
SyntaxErrors can also occur across multiple lines (in fact, across the
rest of a file). In the event of a "multi-line" SyntaxError, we need to
determine what row to report and what the column number is.

For now, we're going to use the row number of the first line and limit
the column number to be less than the end of the line. It may not be
perfect, but it is slightly better.

Related-to #237  
Closes #259 

cc @arcanemagus

See merge request !151
2016-11-20 01:29:46 +00:00
Ian Cordasco
78e8165b06
Skip filename pattern check for provided files
By default, when discovering files for users, we use the filename
patterns to determine whether or not we should check that file. However,
when a user provides the path to a file, we should instead skip checking
the name against the filename patterns provided.

For example, in Flake8 2.6 this worked:

    $ flake8 bin/script.py
    $ flake8 bin/script

But prior to this commit only

    $ flake8 bin/script.py

works. This commit will skip the filename pattern check if the user
provides the path explicitly which allows

    $ flake8 bin/script

to work again as expected.

Closes #266
2016-11-19 08:21:36 -06:00
Ian Cordasco
07c187b8d3
Handle SyntaxErrors in a slightly smarter way
SyntaxErrors are strange and mystical beasts. On top of the problems we
encountered previously in GitLab#237, it's now apparent that
SyntaxErrors can also occur across multiple lines (in fact, across the
rest of a file). In the event of a "multi-line" SyntaxError, we need to
determine what row to report and what the column number is.

For now, we're going to use the row number of the first line and limit
the column number to be less than the end of the line. It may not be
perfect, but it is slightly better.

Related-to #237
Closes #259
2016-11-17 17:17:48 -06:00
Ian Cordasco
c50b747a1a
Fix subtle reporting bug for default on plugins
When we refactored our decision process to fix #239, we broke a subtle
corner case where extensions that are not off-by-default are to be
reported.

This further refactors that logic and adds specific tests around it to
ensure it works as expected and doesn't regress.

Closes #257
2016-11-15 19:56:18 -06:00
Ian Cordasco
8e4905279c
Prepare for 3.2.1 development 2016-11-15 19:48:47 -06:00
Ian Cordasco
e727bbb38b
Release 3.2.0 2016-11-14 16:38:27 -06:00
Ian Cordasco
64cbc6559d
Add release notes for 3.1.1
Bump the version string as well
2016-11-14 09:54:58 -06:00
Ian Cordasco
2197c2ea15
Correct exclude paths in git hook
When running the git hook, even though the appropriate config file is
found and processed, the exclude patterns and paths were not being
corrected to account for the temporary directory that we copy the files
into.

Related-to #223
2016-11-13 14:48:18 -06:00
Ian Cordasco
3fecbe177d
Prepare to release 3.1.0 on 2016-11-14 2016-11-12 14:54:32 -06:00
Ian Cordasco
c81a403fef
Exit non-zero if something goes wrong during a run
If we handle an exception, or early exit, or really anything, we should
exit non-zero (and we used to). This was a minor oversight.

Closes #209
Closes #248
2016-11-12 13:43:49 -06:00
Ian Cordasco
72eecbddcd Merge branch 'bug/245' into 'master'
Do not print the source when provided with -q

When users specify any number of -q's on the command-line, we should not
show the source even if they have otherwwise configured Flake8 to do so.

Closes #245

See merge request !140
2016-11-12 01:10:36 +00:00
Ian Cordasco
5dfb93c0d0
Do not print the source when provided with -q
When users specify any number of -q's on the command-line, we should not
show the source even if they have otherwwise configured Flake8 to do so.

Closes #245
2016-11-11 19:06:13 -06:00
Ian Cordasco
1dfd6bae77
Actually remove enabled extensions from ignore list
When we enable a plugin (when it's provided in the --enable-extensions)
plugin, we need to remove it both from the extended default ignore list
and the plain ignore list.

Closes #239
2016-11-09 18:47:57 -06:00
Ian Cordasco
5b1d84f0ec Merge branch 'bug/223' into 'master'
Change how we initialize our git hook application

Look for configuration files in the current directory while checking the
files in the temporary directory.

Closes #223 

Closes #210 

See merge request !136
2016-11-09 18:02:19 +00:00
Ian Cordasco
9139d11760
Exit early if the diff is empty
In case the provided diff is empty, do not run checks against any files,
simply exit.

Closes #226
2016-11-08 21:38:50 -06:00
Ian Cordasco
7320cce02b
Change how we initialize our git hook application
Look for configuration files in the current directory while checking the
files in the temporary directory.

Closes #210
Closes #223
2016-11-08 21:17:24 -06:00
Ian Cordasco
c2ef3c2ce0 Merge branch 'master' into 'master'
Fixed E305: expected 2 blank lines after class or function definition

See merge request !135
2016-11-09 02:32:25 +00:00
Ian Cordasco
35a35c2a61 Merge branch 'pycodestyle21' into 'master'
Add previous_unindented_logical_line attribute

This attribute is introduced in pycodestyle 2.1.0

Closes #246

See: https://github.com/PyCQA/pycodestyle/issues/400

See merge request !134
2016-11-09 02:31:15 +00:00
Ian Cordasco
4f04ca549b
Handle a previously unhandled code scenario
Previously, we didn't handle the case where an error code was implicitly
ignored (by not being in --select) and implicitly selected (by not being
in --ignore). This means we need to update StyleGuide#_decision_for and
StyleGuide#is_user_selected to handle these cases.

Closes #242
Related-to #239
Related-to !132
2016-11-08 20:00:01 -06:00
Ondřej Nový
901869731b Fixed E305: expected 2 blank lines after class or function definition 2016-11-08 20:13:53 +01:00
Yen Chi Hsuan
6595d3a08d Add previous_unindented_logical_line attribute
This attribute is introduced in pycodestyle 2.1.0

Closes #246

See: https://github.com/PyCQA/pycodestyle/issues/400
2016-11-08 23:34:56 +08:00
Ian Cordasco
352a7250b7
Handle empty stdin-display-name values
Apparently, some folks pass an empty string to --stdin-display-name. To
avoid the errors this causes, we need to handle it appropriately.

Closes #235
2016-10-28 07:09:43 -05:00