conans/client/cmd/export.py
Function _replace_scm_data_in_conanfile
has a Cognitive Complexity of 68 (exceeds 20 allowed). Consider refactoring. Open
Open
def _replace_scm_data_in_conanfile(conanfile_path, scm_data):
# FIXME: Remove in Conan 2.0, it will use conandata.yml as the only way
# Parsing and replacing the SCM field
content = load(conanfile_path)
headers = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function cmd_export
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
def cmd_export(app, conanfile_path, name, version, user, channel, keep_source,
export=True, graph_lock=None, ignore_dirty=False):
""" Export the recipe
param conanfile_path: the original source directory of the user containing a
conanfile.py
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
Open
if isinstance(stmt.targets[0], ast.Name) and stmt.targets[0].id == "scm":
try:
if i + 1 == len(statements): # Last statement in my ClassDef
if i_body + 1 == len(tree.body): # Last statement over all
next_line = len(lines)
Avoid too many return
statements within this function. Open
Open
return scm_data, local_src_path
Visually indented line with same indent as next logical line Open
Open
next_line_content.endswith("'''")):
- Read upRead up
- Exclude checks
Continuation lines indentation.
Continuation lines should align wrapped elements either vertically
using Python's implicit line joining inside parentheses, brackets
and braces, or using a hanging indent.
When using a hanging indent these considerations should be applied:
- there should be no arguments on the first line, and
- further indentation should be used to clearly distinguish itself
as a continuation line.
Okay: a = (\n)
E123: a = (\n )
Okay: a = (\n 42)
E121: a = (\n 42)
E122: a = (\n42)
E123: a = (\n 42\n )
E124: a = (24,\n 42\n)
E125: if (\n b):\n pass
E126: a = (\n 42)
E127: a = (24,\n 42)
E128: a = (24,\n 42)
E129: if (a or\n b):\n pass
E131: a = (\n 42\n 24)