Commit graph

48 commits

Author SHA1 Message Date
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
b9658eaaae Merge branch 'bug/180' into 'master'
Handle repeated --quiet options again

*Description of changes*

Handle `-q`/`--quiet` again.

*Related to:*  #180

See merge request !89
2016-07-26 00:41:08 +00:00
Ian Cordasco
222292c4b2
Handle repeated --quiet options again
Fundamentally on Flake8 2.x using -q altered the format of the errors
(and the behaviour a little) so it makes the most sense to implement
this logic with formatters rather than messy logic spread throughout
the project.

The FilenameOnly formatter will keep track of filenames already reported
and only print the name once while Nothing will print nothing.

Closes #180
2016-07-25 19:38:19 -05:00
Ian Cordasco
667a01f8df Merge branch 'bug/180' into 'master'
Wire-up --statistics again

*Description of changes*

Make `--statistics` work again

*Related to:*  #180

See merge request !87
2016-07-25 19:57:36 +00:00
Ian Cordasco
4dc1d11a62
Wire-up --statistics again
I'm not sure where this code went or when, but it disappeared. Let's
add it back.

Related #180
2016-07-25 14:29:09 -05:00
Ian Cordasco
559e08a09f
Set-up and stop our formatter
Without calling start and stop, our output file is not used by our
Formatters and any formatting plugins.

Related #180
2016-07-25 14:11:53 -05:00
Ian Cordasco
299e200cb9
Handle multiline strings with '# noqa'
In Flake8 2.x we allowed people to use # noqa at the end of a multiline
string to ignore errors inside the string (e.g., E501). Being blissfully
ignorant of this, I never accounted for it in Flake8 3. This fixes the
oversight and allows multiline statements to have the # noqa at the end.

Closes #177
2016-07-25 11:00:18 -05:00
Ian Cordasco
ff0bf5f0f9
Update release notes and version string for 3.0 2016-07-24 20:11:48 -05:00
Fabian Neundorf
373eb15573 Support functions as file plugins too
It is possible to write plugins which are only a function. At the moment they
are called on each line manually. This allows the function also to be called
on each file once. It works similar to creating the class and calling `run` on
it immediately. The plugin function needs to return a generator.

This is based on the original comment in the `FileChecker.run_ast_checks`
method, but slightly modified as the original comment would've called the
return of the function. But the function could return the reports directly.
2016-07-24 16:27:05 +02:00
Ian Cordasco
4a46412bf6
Check for alternate_separator only when truthy
In the case where alternate separator is None, we use '' which will
always be in any string. We want to skip that case.

Also we only run our tests on AppVeyor, not all of our testenvs.
2016-07-22 17:12:49 -05:00
Ian Cordasco
473106fee1
Check for both os.path.sep and os.path.altsep
When normalizing paths, we want to handle the following cases:

- Someone is using a Windows-style path on Windows
- Someone is using a Unix style path on Unix
- Someone is using a Unix style path on Windows

os.path.sep will handle the native directory separator character while
os.path.altsep (when set) will handle alternate separators. Further,
os.path.abspath does the right thing on Windows when handed a Unix-style
path.

Related to #175
2016-07-22 17:07:52 -05:00
Fabian Neundorf
965d6f9509 Fix typo in documentation using indect
The documentation for the `FileProcessor` class used `indect_char` while the
class itself uses the more sensible name `indent_char`. This updates both the
docstring as well as the documentation.
2016-07-21 13:59:07 +02: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
Leonardo Rochael Almeida
b2b4cae8e3 Allow stdin and directly named files to be excluded from check
For the sake of IDEs, check filename for exclusion even if the file is directly
named in the command line.

Also, if the filename is "-" (stdin) check the provided display name for
exclusion.

Also, avoid calling path checking functions on the "-" filename:

 * fnmatch.fnmatch()
 * os.path.isdir()
 * os.path.exists()
2016-07-20 18:45:01 -03:00
Ian Cordasco
9f2eac7df1 Merge branch 'legacy-api-tests' into 'master'
Add Legacy API unit tests

*Description of changes*

Add unit tests around the legacy API.

*Related to:*  n/a

See merge request !76
2016-07-19 16:26:42 +00:00
Ian Cordasco
21a6df725b
Add a bunch more legacy API tests 2016-07-19 11:12:51 -05:00
Sabbir Muhit
b712405586 Fix git config parsing
Since the "git config" command adds a newline to the end of its output, the extraneous whitespace needs to be stripped out for proper parsing.

Fixes #170
2016-07-18 22:44:45 -04: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
43df3ecf74
Use raw strings for docstring 2016-07-14 08:18:38 -05:00
Ian Cordasco
ec678de427
Document Legacy API 2016-07-14 08:13:10 -05:00
Ian Cordasco
911c69f0fd
Fix up docstrings and __all__ in api.legacy
If users do `from flake8.api.legacy import *` we only want them to get
get_style_guide imported. The other classes are not meant to be created
by users.
2016-07-14 07:47:10 -05:00
Ian Cordasco
dc05fce516
Run the individual methods in Application#initialize
We need to initialize part of the Application so we can set options
passed by the user, but we also want to delay making things, e.g.,

- Formatter
- Style Guide
- etc.

Until we have the options solidified so we don't have to do annoying
things.
2016-07-14 07:45:08 -05:00
Ian Cordasco
2ffcf96b4b
Use statistics in the legacy report class 2016-07-12 20:04:20 -05:00
Ian Cordasco
14cab7e81b
Add statistics collection to StyleGuide 2016-07-12 20:04:04 -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
6cfb292b1b
Add the statistics module 2016-07-11 20:13:41 -05:00
Ian Cordasco
57e82688df
Handle errors reported in empty files
Some plugins (e.g., flake8-future-import) report errors for empty
files. Those plugins default to reporting the line number as 1 which
caused earlier versions of Flake8 3.0 beta to crash on an IndexError

Closes #157
2016-07-09 20:21:26 -05:00
Ian Cordasco
ae794fb46a
Update setuptools integration for setup.cfg
When flake8's config is in setup.cfg, setuptools attempts to set those
options on the command instance. If they don't exist, it fails early
complaining that a specific option does not exist.

This adds this back and does it better than the Flake8 2.x version.

Closes #163
2016-07-09 07:02:27 -05:00
Ian Cordasco
1372d0dd1c
Handle kwargs passed to get_style_guide 2016-07-07 17:39:02 -05:00
Ian Cordasco
a4ce229fb6
Fill in most of the legacy API
This does not handle setting custom options via the parameters to
get_style_guide.
2016-07-07 13:29:53 -05:00
Ian Cordasco
6a2ad045fa
Add the skeleton for the LegacyStyleGuide 2016-06-30 08:27:32 -05:00
Ian Cordasco
f963641e93
Update defaults
McCabe reports C90* not C* and Flake8 2 used to exclude .eggs and *.egg
2016-06-30 06:54:10 -05:00
Ian Cordasco
8f5348136f
Remove exc_info for logging.exception
It's redundant and the docs say explicitly that it's ignored.
2016-06-29 15:22:22 -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
15745558c1
Iterate over the checkers fewer times 2016-06-28 20:27:29 -05:00
Ian Cordasco
d8665435a5
Bump version for next beta release 2016-06-28 20:26:50 -05:00
Ian Cordasco
84af24f240
Fix some logging and logging levels 2016-06-28 13:21:22 -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
ec2e601cbf
Enable plugins automatically during registration
Previously the --select was only ever populated to E,F,W,C and so
plugins would not be reported when not off-by-default. This adds a
tiny shim so that we enable plugins that are not off-by-default and
:x
:x
2016-06-28 07:42:51 -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
Ian Cordasco
95c373cf11
Handle EarlyQuits and KeyboardInterrupts 2016-06-26 20:29:13 -05:00
Ian Cordasco
b194717d1a
Search current directory if no paths are specified
This fixes a regression in behaviour from 2.x to 3.

Closes #150
2016-06-26 15:08:58 -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
cee691059f
Merge branch 'origin/proposed/3.0' into master 2016-06-25 12:01:02 -05: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