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.
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.
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
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
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
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
This adds two new methods to the BaseFormatter class:
- beginning
- finished
These will indicate when Flake8 begins and finishes processing a file.
Closes#251
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.
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
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#209Closes#248
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
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
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
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
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
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
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
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
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.
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
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
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
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
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).