Showing 68 of 68 total issues
Too many blank lines (2) Open
Open
def build(self):
- Read upRead up
- Exclude checks
Separate top-level function and class definitions with two blank lines.
Method definitions inside a class are separated by a single blank
line.
Extra blank lines may be used (sparingly) to separate groups of
related functions. Blank lines may be omitted between a bunch of
related one-liners (e.g. a set of dummy implementations).
Use blank lines in functions, sparingly, to indicate logical
sections.
Okay: def a():\n pass\n\n\ndef b():\n pass
Okay: def a():\n pass\n\n\nasync def b():\n pass
Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass
Okay: default = 1\nfoo = 1
Okay: classify = 1\nfoo = 1
E301: class Foo:\n b = 0\n def bar():\n pass
E302: def a():\n pass\n\ndef b(n):\n pass
E302: def a():\n pass\n\nasync def b(n):\n pass
E303: def a():\n pass\n\n\n\ndef b(n):\n pass
E303: def a():\n\n\n\n pass
E304: @decorator\n\ndef a():\n pass
E305: def a():\n pass\na()
E306: def a():\n def b():\n pass\n def c():\n pass
Missing whitespace around operator Open
Open
self.docker_client=docker.client("tcp:/"+":".join([ip.strip(), port.strip()]))
- Read upRead up
- Exclude checks
Surround operators with a single space on either side.
- Always surround these binary operators with a single space on
either side: assignment (=), augmented assignment (+=, -= etc.),
comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
Booleans (and, or, not).
- If operators with different priorities are used, consider adding
whitespace around the operators with the lowest priorities.
Okay: i = i + 1
Okay: submitted += 1
Okay: x = x * 2 - 1
Okay: hypot2 = x * x + y * y
Okay: c = (a + b) * (a - b)
Okay: foo(bar, key='word', *args, **kwargs)
Okay: alpha[:-i]
E225: i=i+1
E225: submitted +=1
E225: x = x /2 - 1
E225: z = x **y
E225: z = 1and 1
E226: c = (a+b) * (a-b)
E226: hypot2 = x*x + y*y
E227: c = a|b
E228: msg = fmt%(errno, errmsg)
Refactor this function to reduce its Cognitive Complexity from 27 to the 15 allowed. Open
Open
def __init__(self, roscommand, config, dockerfile=None):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Replace print statement by built-in function. Open
Open
print "#############################################################"
- Read upRead up
- Exclude checks
The print
statement was removed in Python 3.0. The built-in function should be used instead.
Noncompliant Code Example
print '1' # Noncompliant
Compliant Solution
print('1')
Merge this if statement with the enclosing one. Open
Open
if os.path.samefile(in_fname, dockerfile_fname):
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if condition1: if condition2: # ...
Compliant Solution
if condition1 and condition2: # ...
Replace print statement by built-in function. Open
Open
print l.strip()
- Read upRead up
- Exclude checks
The print
statement was removed in Python 3.0. The built-in function should be used instead.
Noncompliant Code Example
print '1' # Noncompliant
Compliant Solution
print('1')
Use of unsafe yaml load. Allows instantiation of arbitrary objects. Consider yaml.safe_load(). Open
Open
config = yaml.load(open(fname))
- Exclude checks
Replace print statement by built-in function. Open
Open
print "Dockerfile used: ############################################"
- Read upRead up
- Exclude checks
The print
statement was removed in Python 3.0. The built-in function should be used instead.
Noncompliant Code Example
print '1' # Noncompliant
Compliant Solution
print('1')