Conditions | 8 |
Total Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned |
||
42 | def describe_update(): |
||
43 | |||
44 | @pytest.fixture |
||
45 | def slug(): |
||
46 | return SLUG + "/update" |
||
47 | |||
48 | def it_can_update_metrics(env, slug): |
||
49 | cmd = cli(env, slug, 'unit', '100') |
||
50 | |||
51 | expect(cmd.returncode) == 0 |
||
52 | expect(cmd.stderr) == "" |
||
53 | expect(cmd.stdout) == "" |
||
54 | |||
55 | def it_indicates_when_metrics_decrease(env, slug): |
||
56 | cmd = cli(env, slug, 'unit', '0') |
||
57 | |||
58 | expect(cmd.returncode) == 0 |
||
59 | expect(cmd.stderr) == "" |
||
60 | expect(cmd.stdout).contains("coverage decreased") |
||
61 | expect(cmd.stdout).contains( |
||
62 | "To reset metrics, run: coverage.space " + slug + " --reset" |
||
63 | ) |
||
64 | |||
65 | def it_fails_when_metrics_decrease_if_requested(env, slug): |
||
66 | cmd = cli(env, slug, 'unit', '0', '--exit-code') |
||
67 | |||
68 | expect(cmd.returncode) == 1 |
||
69 | expect(cmd.stderr) == "" |
||
70 | expect(cmd.stdout).contains("coverage decreased") |
||
71 | |||
72 | def it_always_display_metrics_when_verbose(env, slug): |
||
73 | cmd = cli(env, slug, 'unit', '100', '--verbose') |
||
74 | |||
75 | expect(cmd.returncode) == 0 |
||
76 | expect(cmd.stderr) != "" # expect lots of logging |
||
77 | expect(cmd.stdout).contains("coverage increased") |
||
78 | |||
79 | def it_skips_when_running_on_ci(env, slug): |
||
80 | env.environ['CI'] = 'true' |
||
81 | |||
82 | cmd = cli(env, slug, 'unit', '0', '--exit-code', '--verbose') |
||
83 | |||
84 | expect(cmd.returncode) == 0 |
||
85 | expect(cmd.stderr).contains("Coverage check skipped") |
||
86 | expect(cmd.stdout) == "" |
||
87 | |||
88 | def it_fails_on_slugs_missing_a_slash(env): |
||
89 | cmd = cli(env, 'foobar', 'unit', '100') |
||
90 | |||
91 | expect(cmd.returncode) == 1 |
||
92 | expect(cmd.stderr).contains( |
||
93 | "<owner/repo> slug must contain a slash") |
||
94 | expect(cmd.stdout) == "" |
||
95 | |||
108 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.