Skip to content

Commit

Permalink
Merge pull request #99 from carlio/feature/error-symbols
Browse files Browse the repository at this point in the history
Using pylint symbols instead of codes for better readability
  • Loading branch information
carlio committed Jan 13, 2015
2 parents 05ffe61 + e90168f commit 47160a9
Show file tree
Hide file tree
Showing 35 changed files with 222 additions and 388 deletions.
6 changes: 3 additions & 3 deletions .prospector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pyroma:

pylint:
disable:
- W0141
- R0903
- C0111
- bad-builtin
- too-few-public-methods
- missing-docstring

pep8:
full: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Prospector Changelog
=======

## Version 0.9
* Messages now use Pylint error symbols ('star-args') instead of codes ('W0142'). This makes it much more obvious what each message means and what is happening when errors are suppressed or ignored in profiles. The old error codes will continue to work in profiles.
* The way that profiles are handled and parsed has completely been rewritten to avoid several bugs and introduce 'shorthand' options to profiles. This allows profiles to specify simple options like 'doc-warnings: true' inside profiles and configure anything that can be configured as a command line argument. Profiles can now use options like 'strictness: high' or 'doc-warnings: true' as a shortcut for inheriting the built-in prospector profiles.
* A new `--show-profile` option is available to dump the calculated profile, which is helpful for figuring out what prospector thinks it is doing.
* Profiles now have separate `ignore-paths` and `ignore-patterns` directives to match the command line arguments. The old `ignore` directive remains in place for backwards compatibility and will be deprecated in the future.
Expand Down
8 changes: 4 additions & 4 deletions docs/profiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ The typical desired action is to disable messages::

pylint:
disable:
- E0202
- E0203
- method-hidden
- access-member-before-definition

However, you can also enable messages which were disabled by parent profiles::

pylint:
enable:
- E0202
- E0203
- method-hidden
- access-member-before-definition


Tool Options
Expand Down
2 changes: 1 addition & 1 deletion prospector/autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def autodetect_libraries(path):
try:
libraries = find_from_requirements(path)

# pylint: disable=W0704
# pylint: disable=pointless-except
except RequirementsNotFound:
pass

Expand Down
11 changes: 6 additions & 5 deletions prospector/blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ def blend_line(messages, blend_combos=None):
if blend_list[0] not in blended:
# We may have already added this message if it represents
# several messages in other tools which are not being run -
# for example, pylint C0111 is blended with pep257 D100, D101
# for example, pylint missing-docstring is blended with pep257 D100, D101
# and D102, but should not appear 3 times!
blended.append(blend_list[0])

# Some messages from a tool point out an error that in another tool is handled by two
# different errors or more. For example, pylint emits the same warning (C0321) for "two statements on a line"
# separated by a colon and a semi-colon, while pep8 has E701 and E702 for those cases respectively. In
# this case, the pylint error will not be 'blended' as it will appear in two blend_lists. Therefore we
# mark anything not taken from the blend list as "consumed" and then filter later, to avoid such cases.
# different errors or more. For example, pylint emits the same warning (multiple-statements)
# for "two statements on a line" separated by a colon and a semi-colon, while pep8 has E701
# and E702 for those cases respectively. In this case, the pylint error will not be 'blended' as
# it will appear in two blend_lists. Therefore we mark anything not taken from the blend list
# as "consumed" and then filter later, to avoid such cases.
for now_used in blend_list[1:]:
now_used.used = True

Expand Down
76 changes: 38 additions & 38 deletions prospector/blender_combinations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,109 +7,109 @@

combinations:
- # Unused Import
- pylint: W0611
- pylint: unused-import
- pyflakes: FL0001
- frosted: E101

- # Syntax Error
- dodgy: diff
- pylint: E0001
- pylint: syntax-error
- pyflakes: FL9998
- pep8: E901
- mccabe: MC0000
- frosted: E402

- # Undefined local variable
- pylint: E0602
- pylint: undefined-variable
- pyflakes: FL0006
- frosted: E303

- # Unused variable
- pylint: W0612
- pylint: unused-variable
- vulture: unused-variable
- pyflakes: FL0013
- frosted: E307

- # Mixed tabs and spaces
- pep257: D206
- pep8: E101
- pylint: W0313
- pylint: indentation-mixture

- # Import from __future__ not first import
- pylint: W0410
- pylint: misplaced-future
- pyflakes: FL0012
- frosted: E207

- # Line too long
- pep8: E501
- pylint: C0301
- pylint: line-too-long

- # Trailing whitespace
- pep8: W291
- pylint: C0303
- pylint: trailing-whitespace

- # Blank line contains whitespace
- pep8: W293
- pylint: C0303
- pylint: trailing-whitespace

- # No newline at end of file
- pep8: W292
- pylint: C0304
- pylint: missing-final-newline

- # line ends with semi-colon
- pep8: E703
- pylint: W0301
- pylint: unnecessary-semicolon

- # multiple statements on one line (colon)
- pep8: E701
- pylint: C0321
- pylint: multiple-statements

- # multiple statements on one line (semicolon)
- pep8: E702
- pylint: C0321
- pylint: multiple-statements

- # incorrect indendation
- pep257: D207
- pep8: E111
- pylint: W0311
- pylint: bad-indentation

- # incorrect indendation
- pep257: D208
- pep8: E111
- pylint: W0311
- pylint: bad-indentation

- # comma not followed by a space
- pep8: E231
- pylint: C0324
- pylint: C0326
- pylint: bad-whitespace

- # missing whitespace around operator
- pep8: E225
- pylint: C0322
- pylint: C0326
- pylint: bad-whitespace

- # missing whitespace around operator
- pep8: E225
- pylint: C0323
- pylint: C0326
- pylint: bad-whitespace

- # undefined name in __all__
- pylint: E0603
- pylint: undefined-all-variable
- pyflakes: FL0008
- frosted: E304

- # duplicate argument in function definition
- pylint: E0108
- pylint: duplicate-argument-name
- pyflakes: FL0010
- frosted: E206

- # redefinition of unused function
- pyflakes: FL0002
- pylint: E0102
- pylint: function-redefined

- # first argument of a classmethod should be named 'cls'
- pep8: N804
- pylint: C0202
- pylint: bad-classmethod-argument

- # '<>' is deprecated, use '!='
- pep8: W603
Expand All @@ -120,42 +120,42 @@ combinations:
- pylint: W0333

- # Redefining name from outer scope
- pylint: W0621
- pylint: redefined-outer-name
- pyflakes: FL0011
- frosted: E306

- # Wildcard import
- pylint: W0401
- pylint: wildcard-import
- pyflakes: FL0005
- frosted: E103

- # Return with argument inside generator
- pylint: E0106
- pylint: return-arg-in-generator
- frosted: E208

- # Too many positional arguments for function call
- pylint: E1121
- pylint: too-many-function-args
- frosted: E203

- # Passing unexpected keyword argument
- pylint: E1123
- pylint: unexpected-keyword-arg
- frosted: E204

- # Missing mandatory keyword argument
- pylint: E1125
- pylint: missing-kwoa
- frosted: E205

- # No exception type(s) specified
- pylint: W0702
- pylint: bare-except
- frosted: W101

- # Spaces around keyword/paramater equals
- pep8: E251
- pylint: C0326
- pylint: bad-whitespace

- # Missing space after a comma
- pep8: E231
- pylint: C0326
- pylint: bad-whitespace

- # redefinition of unused %r from line %r
- pyflakes: FL0002
Expand All @@ -178,29 +178,29 @@ combinations:
- frosted: E305

- # pep8-naming incorrectly suggests that the first argument of a metaclass __new__ method should be 'cls'
- pylint: C0204
- pylint: bad-mcs-classmethod-argument
- pep8: N804

- # class names should be camelcase
- pep8: N801
- pylint: C0103
- pylint: invalid-name

- # too complex
- mccabe: MC0001
- pylint: R0912
- pylint: too-many-branches

- # pep257 takes preference over pylint documentation warnings
- pep257: D100
- pylint: C0111
- pylint: missing-docstring

-
- pep257: D101
- pylint: C0111
- pylint: missing-docstring

-
- pep257: D102
- pylint: C0111
- pylint: missing-docstring

-
- pep257: D103
- pylint: C0111
- pylint: missing-docstring
2 changes: 1 addition & 1 deletion prospector/formatters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)


# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class Formatter(object):
def __init__(self, summary, messages, profile):
self.summary = summary
Expand Down
2 changes: 1 addition & 1 deletion prospector/formatters/grouped.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def render_messages(self):
'',
]

# pylint: disable=W0108
# pylint: disable=unnecessary-lambda
groups = defaultdict(lambda: defaultdict(list))

for message in self.messages:
Expand Down
2 changes: 1 addition & 1 deletion prospector/formatters/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)


# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class JsonFormatter(Formatter):
def render(self, summary=True, messages=True, profile=False):
output = {}
Expand Down
2 changes: 1 addition & 1 deletion prospector/formatters/pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def render(self, summary=True, messages=True, profile=False):
output.append(header)

# ={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
# prospector/configuration.py:65: [C0111(missing-docstring), build_default_sources] \
# prospector/configuration.py:65: [missing-docstring(missing-docstring), build_default_sources] \
# Missing function docstring

template = '%(path)s:%(line)s: [%(code)s(%(source)s), %(function)s] %(message)s'
Expand Down
4 changes: 2 additions & 2 deletions prospector/formatters/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
)


# pylint: disable=W0108
# pylint: disable=unnecessary-lambda


class TextFormatter(Formatter):
Expand Down Expand Up @@ -48,7 +48,7 @@ def render_summary(self):

return '\n'.join(output)

# pylint: disable=R0201
# pylint: disable=no-self-use
def render_message(self, message):
output = []

Expand Down
2 changes: 1 addition & 1 deletion prospector/formatters/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)


# pylint: disable=R0903
# pylint: disable=too-few-public-methods
class YamlFormatter(Formatter):
def render(self, summary=True, messages=True, profile=False):
output = {}
Expand Down
Loading

0 comments on commit 47160a9

Please sign in to comment.