Commit graph

109 commits

Author SHA1 Message Date
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
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
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
Ian Cordasco
33f982b446 Rely on Python 3.4 backport of configparser
Python 2.7's ConfigParser module does not allow for the behaviour we
have documented for config files in Flake8 3.0. To compensate for that,
we add a dependency on the configparser backport on PyPI for Python 2.7
2016-05-30 12:51:31 -05:00
Ian Cordasco
466ef2e596 Add example configuration sections to the docs
Add tests to verify our examples do not regress
2016-05-28 12:00:47 -05:00
Ian Cordasco
91e07ebcff Refactor off-by-default plugins and enabling them
We move the logic to add or remove a plugin from the default ignore
list to individual methods on the Plugin class (Plugin#enable,
Plugin#disable) and use that when registering and parsing options.

If the plugin is off-by-default, Plugin#register_options will use
Plugin#disable. When parsing options via Plugin#provide_options, if
the plugin has been specified in --enable-extensions then it will be
re-enabled via Plugin#enable.
2016-05-28 11:57:18 -05:00
Ian Cordasco
559922dbbc Update tests after last night's refactor 2016-05-10 16:37:45 -05:00
Ian Cordasco
e32476b671 Add test for the make_checkers method 2016-05-07 19:07:14 -05:00
Ian Cordasco
102037788d Fix import ordering 2016-04-05 18:54:28 -05:00
Ian Cordasco
78b986d506 Refactor checker manager and add tests 2016-04-05 18:52:35 -05:00
Ian Cordasco
eb3d8f5791 Add unit tests around serial retries 2016-04-03 14:41:12 -05:00
Ian Cordasco
81eb3e41cc Add more processor tests 2016-04-02 11:13:23 -05:00
Ian Cordasco
425f89eee9 Add more tests around the processor module 2016-03-29 08:07:15 -05:00
Ian Cordasco
4ea161ff9c Add a few more unit tests around FileProcessor 2016-03-28 21:04:34 -05:00
Ian Cordasco
7de8a058dd Add unit test for build_ast 2016-03-28 19:43:14 -05:00
Ian Cordasco
698af80514 Add test for FileProcessor#split_line 2016-03-27 14:32:21 -05:00
Ian Cordasco
82dd4f6d25 Add more FileProcessor tests 2016-03-26 08:51:58 -05:00
Ian Cordasco
5554ef78cf Silence pytest warnings 2016-03-26 08:51:21 -05:00