-
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import subprocess | ||
|
||
|
||
def test_max_variables_cli_option(absolute_path): | ||
"""Test to check max-local-variables cli option.""" | ||
filename = absolute_path('fixtures', 'complexity', 'wrong_variables.py') | ||
option_flag = '--max-local-variables' | ||
option_value = '100' | ||
process = subprocess.Popen( | ||
['flake8', filename, option_flag, option_value], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
stdout, _ = process.communicate() | ||
assert stdout.count(b'WPS150') == 0 | ||
|
||
|
||
def test_max_arguments_cli_option(absolute_path): | ||
"""Test to check max-arguments cli option.""" | ||
filename = absolute_path('fixtures', 'complexity', 'wrong_arguments.py') | ||
option_flag = '--max-arguments' | ||
option_value = '100' | ||
process = subprocess.Popen( | ||
['flake8', filename, option_flag, option_value], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
stdout, _ = process.communicate() | ||
assert stdout.count(b'WPS151') == 0 | ||
|
||
|
||
def test_max_returns_cli_option(absolute_path): | ||
"""Test to check max-returns cli option.""" | ||
filename = absolute_path('fixtures', 'complexity', 'wrong_returns.py') | ||
option_flag = '--max-returns' | ||
option_value = '100' | ||
process = subprocess.Popen( | ||
['flake8', filename, option_flag, option_value], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
stdout, _ = process.communicate() | ||
assert stdout.count(b'WPS153') == 0 | ||
|
||
|
||
def test_max_expressions_cli_options(absolute_path): | ||
"""Test to check max-expressions cli option.""" | ||
filename = absolute_path('fixtures', 'complexity', 'wrong_expressions.py') | ||
option_flag = '--max-expressions' | ||
option_value = '100' | ||
process = subprocess.Popen( | ||
['flake8', filename, option_flag, option_value], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
stdout, _ = process.communicate() | ||
assert stdout.count(b'WPS154') == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from wemake_python_styleguide.options import defaults | ||
|
||
|
||
class Configuration(object): | ||
"""Provides method for registering options for WPS flake8 plugin.""" | ||
|
||
def register_options(self, parser): | ||
"""Registers options for WPS plugin.""" | ||
parser.add_option( | ||
'--max-returns', | ||
parse_from_config=True, | ||
type='int', | ||
default=defaults.MAX_RETURNS, | ||
help='Maximum allowed number of return statements in one function.', | ||
) | ||
|
||
parser.add_option( | ||
'--max-local-variables', | ||
parse_from_config=True, | ||
type='int', | ||
default=defaults.MAX_LOCAL_VARIABLES, | ||
help='Maximum allowed number of local variables in one function.', | ||
) | ||
|
||
parser.add_option( | ||
'--max-expressions', | ||
parse_from_config=True, | ||
type='int', | ||
default=defaults.MAX_EXPRESSIONS, | ||
help='Maximum allowed number of expressions in one function.', | ||
) | ||
|
||
parser.add_option( | ||
'--max-arguments', | ||
parse_from_config=True, | ||
type='int', | ||
default=defaults.MAX_ARGUMENTS, | ||
help='Maximum allowed number of arguments in one function.', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Constants with default values for configuration.""" | ||
|
||
MAX_RETURNS = 6 | ||
|
||
MAX_LOCAL_VARIABLES = 10 | ||
|
||
MAX_EXPRESSIONS = 10 | ||
|
||
MAX_ARGUMENTS = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters