Showing 18 of 31 total issues
Function walk_files
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
def walk_files(main_file, path, package, imports=None):
if imports is None:
imports = []
if not desc_file and package == "POGOProtos":
- 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 format_protos
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def format_protos(
protos,
path,
namespace,
path_lower,
- 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
File compile.py
has 426 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
import argparse
import glob
import re
Function merge_protos
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def merge_protos(protos):
new_protos = dict()
for proto_path in protos:
proto_folder = list(protos[proto_path].values())
- 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 walk_directory
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def walk_directory(path):
for dir_name in os.listdir(path):
dir_name_path = os.path.join(path, dir_name)
if os.path.isdir(dir_name_path):
package = get_package(dir_name_path)
- 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 read_proto
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def read_proto(path):
package = None
imports = []
content = []
with open(path, 'r') as file:
- 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 write_proto
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def write_proto(path, name, proto):
package, imports, content = proto
if not os.path.exists(path):
os.makedirs(path)
- 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 get_package
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_package(path):
for file_name in os.listdir(path):
file_name_path = os.path.join(path, file_name)
if os.path.isfile(file_name_path) and file_name.endswith('.proto'):
with open(file_name_path, 'r') as proto_file:
- 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 query_yes_no
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
- 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
if import_is_public:
new_imports_is_public[
new_imports_path.index(import_path)] = True
elif import_path != proto_path:
Avoid deeply nested control flow statements. Open
if is_header:
if proto_line.startswith("import"):
import_from_package_re = re.search('import (public )?"(.*?)(\/)?([a-zA-Z0-9]+\.proto)";',
proto_line)
Function format_protos
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def format_protos(
Avoid deeply nested control flow statements. Open
if not is_header:
messages += proto_line
if proto_line == "}":
messages += "\n"
Avoid deeply nested control flow statements. Open
if import_path_split[1:-1]:
import_path_path = path + '/' + \
'/'.join(import_path_split[1:-1])
else:
import_path_path = path
Function read_protos
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def read_protos(path):
protos = dict()
for folder_path, _, file_names in os.walk(path):
proto_folder = dict()
for file_name in file_names:
- 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
if proto_line.startswith("package"):
return re.search('package (.*?);', proto_line).group(1)
return None
Avoid deeply nested control flow statements. Open
if proto_line.startswith("message") or proto_line.startswith("enum"):
is_header = False
Function finish_compile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def finish_compile(out_path, lang):
if lang == 'python':
pogo_protos_path = os.path.join(out_path, "POGOProtos")
for root, dirnames, filenames in os.walk(pogo_protos_path):
- 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"