Commit graph

111 commits

Author SHA1 Message Date
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
edd84fba52 Merge branch 'bug/157' into 'master'
Handle errors reported in empty files

*Description of changes*

Some plugins return errors in empty files which previously caused an IndexError.

*Related to:*  #157 

See merge request !71
2016-07-10 01:29:17 +00:00
Ian Cordasco
e977c6671a
Update tests for errors with no physical line 2016-07-09 20:26:08 -05:00
Ian Cordasco
8e27f0fbcf
Add empty file as a test fixture 2016-07-09 19:41:47 -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
84456866a5
Fix integration tests 2016-06-14 08:03:48 -05:00
Ian Cordasco
ba7f4db7e9
Add test fixture that mirrors documented usage 2016-06-07 18:46:58 -05:00
Ian Cordasco
4c0b1cd5e1
Fix tests broken by updating the default ignore list 2016-06-07 18:46:43 -05:00
Ian Cordasco
2cd3ac91d1
Start adding test fixture files
This adds E501 which is actually a poor test. Currently,
pep8.maximum_line_length does its own check for noqa instead of relying
on the Checker. See also: https://github.com/PyCQA/pycodestyle/pull/539
2016-06-07 18:03:58 -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
Ian Cordasco
a4cc9d6fa8 Add test for reading from stdin with the file processor 2016-03-21 10:23:27 -05:00
Ian Cordasco
0fd276d5ee Add a test for FileProcessor.should_ignore_file 2016-03-17 15:16:15 -05:00
Ian Cordasco
5cde4bebae Add docstring for our test helper 2016-03-17 15:16:00 -05:00
Ian Cordasco
48b995fa62 Remove unnecessary and outdated test runner 2016-03-17 14:55:57 -05:00
Ian Cordasco
09000762fb Rename test file to mirror actual class it is testing 2016-03-17 09:15:52 -05:00
Ian Cordasco
de9f56addf Fix import ordering in test files 2016-02-25 14:41:37 -06:00
Ian Cordasco
a4e984dbd2 Add and fix documentation
- Add more documentation around utils functions
- Fix documentation about default formatting plugins
- Add extra documentation of filenames_from predicate parameter
- Add test for the default parameter of flake8.utils.fnmatch
2016-02-25 09:06:50 -06:00
Ian Cordasco
24d2689a05 Distinguish check types via plugin type manager
Flake8 and pep8 has historically supported three types of checks:

- Plugins that accept the physical line
- Plugins that accept the logical line
- Plugins that accept the AST tree

The logical place to make this distinction is on the Checkers plugin
type manager class. This adds the foundation for finding plugins that
fall into each class.
2016-02-23 23:20:34 -06:00
Ian Cordasco
5ee061b810 Add line splitting and file reading
Add some tests around reading lines and striping UTF BOMs
2016-02-23 11:17:11 -06:00