Commit graph

124 commits

Author SHA1 Message Date
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
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
Ian Cordasco
f82b5d62d0
Update NOQA regular expression
This allows for other text after `# noqa`.

Related to #180
2016-07-26 06:24:04 -05:00
Ian Cordasco
a1fdb5a2b5
Fix up merge request 78
This simplifies the changes, reduces the scope of refactors apparently
for refactoring's sake and ensures that the internals are reasonable.

It also airs on the side of preserving information rather than
discarding or overwriting it.
2016-07-20 19:28:13 -05:00
Leonardo Rochael Almeida
7934f8dce2 Propagate the stdin_display_name to checker and processor
This way plugins like flake8-putty can have access to the correct filename.
2016-07-20 18:45:01 -03:00
Ian Cordasco
21a6df725b
Add a bunch more legacy API tests 2016-07-19 11:12:51 -05:00
Ian Cordasco
8b4f12872e
Add more simple tests for the legacy api 2016-07-16 21:06:27 -05:00
Ian Cordasco
6e3107001f
Begin adding tests for the Legacy API 2016-07-16 20:27:07 -05:00
Ian Cordasco
73be9b0e90
Add OptionManager#parse_known_args
If a user specified `--max-complexity` on the command-line, they
would be told that it did not exist. The same would be true of any
option provided by a plugin. This is because we parse the command-line
arguments twice in Flake8 -- the first time to specify the verbosity
and destination for logging, the second time to actually execute Flake8.
Since plugin options are not registered to start with the first time,
they are not valid options. So when we first parse the options, we should
only attempt to parse the ones which we know about.

Closes #168
2016-07-16 10:07:19 -05:00
Ian Cordasco
61430951ec
Add more tests around our Statistics class 2016-07-12 19:58:44 -05:00
Ian Cordasco
2d3f062191
Add actual tests around statistics module
Also refactor our statistics module to be a bit smarter and less
namedtuple happy. The Statistic class had no reason to be a tuple,
I have no clue why I wrote it that way last night.
2016-07-12 08:21:57 -05:00
Ian Cordasco
1a722bbe7b
Add empty test file for our statistics module 2016-07-11 20:24:38 -05:00
Ian Cordasco
e977c6671a
Update tests for errors with no physical line 2016-07-09 20:26:08 -05:00
Ian Cordasco
75e1c1efbf
Revert "Prefer .flake8 if present for options."
The intended behaviour already existed.

This reverts commit db9d4ad8b4.
2016-06-28 20:47:16 -05:00
Ian Cordasco
c9fb680dff
Add python and platform details to --version
On Flake8 2.x we added the information about the implementation,
version, and operating system to the --version output to make helping
users easier. In short they can pretty simply just give us the output
from

    flake8 --version

And we can get a lot of the information that we need.
2016-06-28 13:02:50 -05:00
Ian Cordasco
2d3e277b1e
Handle optional parameters that were never supported
Previously, pycodestyle never introspected the argument names for
classes except to require that ``tree`` be an argument it could pass.
For Flake8 3.0, we lifted that restriction, but old plugins seem to
have cargo-culted their __init__ signature to be

    def __init__(self, tree, builtins=None):

For some yet unknown reason. This was causing an AttributeError. By
updating flake8.utils.parameters_for to return a dictionary that
indicates whether the parameter is required or not, we can side-step
this by simply ignoring the parameter if it has a default value and
we cannot provide it.

Closes #151
2016-06-28 09:36:24 -05:00
Ian Cordasco
31c32e3327
Parse hyphenated config names also
Previously Flake8 parsed both

    max-line-length = 110

And

    max_line_length = 110

From the config file without issue. When we updated our logic, I forgot
to test for that and we lost that behaviour temporarily.

Closes #152
2016-06-28 05:47:14 -05:00
Tom Prince
db9d4ad8b4 Prefer .flake8 if present for options.
If somebody explicitly has a `.flake8` file, presumably they intend to
put flake8 configuration in it, so prefer it to the generic `setup.cfg`
and `tox.ini` from pycodestyle.
2016-06-25 14:22:21 -06:00
Ian Cordasco
1a2c68f5da
Move flake8 into src
This is an emerging best practice and there is little reason to not
follow it
2016-06-25 10:12:13 -05:00
Ian Cordasco
8bc76f79de
Configure flake8-import-order to use Google Style
This relies on two things:

1. Properly configuring flake8-import-order to use that style
2. Properly configuring flake8-import-order to know that flake8 is our
   application name.
2016-06-17 10:26:36 -05:00
Ian Cordasco
3f434f7d1c
Add broken config file to test error handling
ConfigFileFinder should absolutely handle broken/invalid config files
by refusing to try to parse them. Here we catch the ParsingError,
log the exception, and then return normally. The RawConfigParser
instance is perfectly valid still and will behave as if nothing had
been read and we just need to indicate that we didn't find any files
worthy of reading.

Related to: https://github.com/PyCQA/pycodestyle/issues/506
2016-06-16 16:19:09 -05:00
Ian Cordasco
9ebaa5c69c
Add tests for parse_unified_diff
We could probably use non-git diff fixtures, but those are what we have
for now.
2016-06-07 10:14:45 -05:00
Ian Cordasco
9ecca93a9b
Add more BaseFormatter subclass tests 2016-06-04 13:02:29 -05:00
Ian Cordasco
d477715064
Fix linting issues 2016-06-04 13:02:09 -05:00
Ian Cordasco
9c2e747528
Add tests around BaseFormatter#after_init 2016-06-04 12:39:11 -05:00
Ian Cordasco
ba2d94888c Add tests for BaseFormatter 2016-06-01 16:56:17 -05:00
Ian Cordasco
15043a4ab7 Update our linecache test to correct it 2016-05-30 16:48:30 -05:00
Ian Cordasco
467672fc5c Refactor Error formatting and handling
This allows us to handle --show-source in our formatters by default.

This also adds the physical line information to the Error class instead
of passing it to is_inline_ignored. This allows us to avoid using
linecache in our formatters.
2016-05-30 16:43:11 -05:00