Commit graph

169 commits

Author SHA1 Message Date
Shinya Kawaguchi
98b9946a78 Reproduce quiet/verbose config problem 2017-07-22 16:18:58 +09:00
Ian Cordasco
ff07ca3ed9
Add some better comments for decision logic 2017-06-04 15:07:10 -05:00
Ian Cordasco
e8c6a1e2f5
Get *one* more line of test coverage
This was mostly to prove to myself that we could possibly reach that
return more than actually covering that return. This just shows how
gnarly this logic actually is. I wish there were a better way to write
it.
2017-06-04 14:51:01 -05:00
Ian Cordasco
92c367dee4
Rename style_guide.Error to style_guide.Violation
Move all Violation related methods from the StyleGuide to our Violation
class.
2017-06-04 07:57:28 -05:00
Ian Cordasco
65107a5624
Rename methods on the new DecisionEngine
Rename `decision_for` to `more_specific_decision_for` and
`should_report_error` to `decision_for`.
2017-06-03 19:20:46 -05:00
Ian Cordasco
583fda7a70
Move unit tests for StyleGuide decision logic
Convert it to test the DecisionEngine class directly and put them in
their own file.
2017-06-02 19:16:28 -05:00
Ian Cordasco
7fef0af0f5
Refactor decision logic into its own object
In dealing with the decision logic in the StyleGuide recently I
recognized that the logic really doesn't belong strictly on the
StyleGuide. A separate object makes perfect sense especially from the
perspective of testability. This is a minor refactor intended solely to
facilitate further testing and perhaps making the logic easier to
understand for others.
2017-06-01 20:36:37 -05:00
Ian Cordasco
feec0754bd
Add debugging utility for FileChecker 2017-06-01 20:06:34 -05:00
Ian Cordasco
fec980a856 Merge branch 'bug/318' into 'master'
Further improve our handling of --select and --ignore

Closes #318

See merge request !187
2017-05-28 01:41:13 +00:00
Ian Cordasco
aefa79535f
Simplify conditoinal in decision logic
Add test to cover branch of decision logic we were not previously
exercising
2017-05-27 20:34:04 -05:00
Ian Cordasco
178092954d
Add extra test cases for violation decisions 2017-05-27 20:16:15 -05:00
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
Jon Dufresne
db4f71288e Prefer iter(dict) instead of dict.keys()
They are equivalent for iterating so remove the additional function
call.

Pattern identified as outdated by Lennart Regebro's PyCon 2017 talk
"Prehistoric Patterns in Python"

https://www.youtube.com/watch?v=V5-JH23Vk0I
2017-05-27 11:54:06 -07: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
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
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
Ian Cordasco
c9ea51aa45
Add test for reproducible --version strings
And add a release note to document the change.
2017-01-21 14:14:59 -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
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
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
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
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
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
Ian Cordasco
68a273144e
Fix bug with --enable-extensions
We went through an iteration where we supported --enable-extensions and
then didn't. This adds back our support for --enable-extensions.

Closes #239
2016-10-25 19:28:52 -05:00
Ian Cordasco
a9e15afbf5 Merge branch 'master' into 'master'
Add --tee option to split report output stream.

The `--tee` option allows the linter report to be written to stdout, even
though it is being redirected to a file with the` --output-file` option.
This is useful if I want to store the report in a separate file for later
analysis but also be able to print the output on screen (e.g when running
in a CI environment).

See merge request !90
2016-10-25 21:34:43 +00:00
Ian Cordasco
941896218d
Change how we apply lazy to the git hook 2016-10-25 05:25:44 -05:00
Ian Cordasco
7998734fe6
Handle SyntaxErrors after new-lines specially
In some cases, when we handle SyntaxErrors we need to ensure that the
column number is correct for a 1-indexed report. In some cases, we also
need to account for the fact that the SyntaxError has happened "after" a
new-line. To extract and alter the row and column numbers, we've moved
the logic to a private static method on the FileChecker object to avoid
an overly complex method.

Closes #237
2016-10-23 07:37:08 -05:00
Ian Cordasco
1631ab8ac7
Add failing test for NoneType in handle_error
There are rare cases when StyleGuide#handle_error might receive None
as the column_number. This adds the failing test to ensure we don't
regress the correct behaviour.

Related-to #214
2016-08-27 19:44:24 -05:00
Ian Cordasco
f67f481bee
Add --bug-report flag to help bug reporters
When invoked it will print out JSON that has all of the debugging
information needed by the maintainers to diagnose or reproduce a bug.

Closes #207
2016-08-07 12:31:14 -05:00
Ian Cordasco
e14d0e6352
Serialize Checkers PluginTypeManager to a dict
It seems likely that the multiprocessing module on Windows is not
capable of serializing an object with the structure that we have and
preserving the attributes we dynamically set on plugins (like the
FlakesChecker). To avoid issues like this with all plugins (although
we have only found this on Windows with the FlakesChecker), let's try
serializing the Checkers PluginTypeManager to a dictionary so that the
only object that a Queue is really trying to serialize/deserialize is
the FlakesChecker itself.

Related to #179
2016-08-03 16:48:39 -05:00
Ian Cordasco
e93aad6043
Open our output file in append mode always
This avoid overwriting portions of our log output when using Flake8
in verbose mode.

Closes #193
2016-07-29 18:14:14 -05:00
Fabian Neundorf
78edfdea63 Test loading non-callable plugins
With d234f22 it did not load plugins which aren't callable. This is adding a
basic test to it.
2016-07-29 18:58:12 +02:00
Ian Cordasco
429d8a196e
Diable multiprocessing behaviour on Windows
Due to https://bugs.python.org/issue27649, we cannot continue to
expect multiprocessing to work as we expect and document it on Windows.
As such, we are going to revert back to our previous behaviour of
disabling it across all versions of Python on Windows to provide the
default expected behaviour of Flake8 on that Operating System.
2016-07-29 07:04:37 -05:00
Ian Cordasco
c670217c24
Allow plugins that are on by default to be ignored
Previously, to ensure that plugins on by default were reported, we
added them to the select list. This means that ignoring them became
impossible. To accomodate our reporting logic and a user's ability
to ignore, we need to keep our select and extended select lists
separated.

This allows us to have a better understanding of who is selecting what,
where, and how and make our decision as to whether or not an error
should be reported more wisely.

Closes #195
2016-07-28 19:28:13 -05:00
Fabian Neundorf
ad3b486909 Sort reports by line and column
Originally the reports have been sorted by column and message (without the
error code), so it didn't order after the line number.

Closes #196
2016-07-28 19:25:13 +02:00
Ian Cordasco
c0ddc54f2f
Match noqa for users with explanations
This makes the regular expression a bit more complex, and potentially
slower, but it will fix the issue where users had noqa comments with
colons followed by explanations.

Closes #178
2016-07-28 06:48:15 -05:00
Ian Cordasco
beee924f16 Merge branch 'read_lines_crlf' into 'master'
Fix read_lines_splits_lines test for CRLF endings

This change makes the test pass for when files are saved with CRLF Windows-style line endings since those are included in various `.readlines()` methods by default.

See merge request !96
2016-07-27 11:27:12 +00:00
FichteFoll
ca02a8c88d Fix read_lines_splits_lines test for CRLF endings 2016-07-27 03:36:20 +02:00
Ian Cordasco
6eca38f2f2
Fix zero-indexed column numbering
We accidentally changed column numbering from one-indexed to
zero-indexed.
2016-07-26 19:45:05 -05:00
Martin Domke
9bfdc867cd Patch print function instead of sys.stdout 2016-07-26 17:27:15 +02:00
Ian Cordasco
df2fa18a08
Fix project config file discovery
Flake8 3.0 was stopping once it found the current directory but the
historical behaviour (that we didn't intend to break) searched past
that (towards root) until it found one of the project/local config
file names that could be read.

Closes #181
2016-07-26 09:37:32 -05:00
Martin Domke
c782060a06 Add --tee option to split report output stream.
The --tee option allows the linter report to be written to stdout, even
though it is being redirected to a file with the --output-file option.
This is useful if I want to store the report in a separate file for later
analysis but also be able to print the output on screen (e.g when running
in a CI environment).
2016-07-26 15:57:13 +02:00