Showing 2,622 of 2,627 total issues
Function _execute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _execute(self, sources, interval):
if self.categorical:
for t, d in sources[0].window(interval, force_calculation=True):
yield StreamInstance(t, dict(map(safe_key, Counter(d).items())))
else:
- Read upRead up
- Create a ticketCreate a ticket
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_stream_writer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_stream_writer(self, stream):
def writer(document_collection):
if stream.stream_id not in self:
raise RuntimeError("Data slot does not exist for {}, perhaps create_stream was not used?"
.format(stream))
- Read upRead up
- Create a ticketCreate a ticket
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 _execute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _execute(self, sources, alignment_stream, interval):
if self.categorical:
for t, d in sources[0].window(interval, force_calculation=True):
yield StreamInstance(t, dict(map(safe_key, Counter(d).items())))
else:
- Read upRead up
- Create a ticketCreate a ticket
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 __init__
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, name, meta_data=None):
self.name = name
if meta_data:
# if isinstance(meta_data, dict):
# keys = sorted(meta_data.keys())
- Read upRead up
- Create a ticketCreate a ticket
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def __init__(self, start, stop=None, step=1, seed=None):
super(Randrange, self).__init__(start=start, stop=stop, step=step, seed=seed)
random.seed(self.seed)
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 37.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def __init__(self, low=0.0, high=1.0, mode=None, seed=None):
super(Triangular, self).__init__(low=low, high=high, mode=mode, seed=seed)
random.seed(self.seed)
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 37.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function create_workflow
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_workflow(self, workflow_id, name, owner, description, online=False, monitor=False, safe=True):
- Create a ticketCreate a ticket
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, channel, stream_id, calculated_intervals, last_accessed, last_updated, sandbox,
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if p not in set(sink.plate_ids):
raise IncompatiblePlatesError("{} not in sink plates".format(p))
plates = sink.plates
- Create a ticketCreate a ticket
Function now_minus
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def now_minus(cls, weeks=0, days=0, hours=0, minutes=0, seconds=0, milliseconds=0):
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if p not in set(source_plates):
raise IncompatiblePlatesError("{} not in source plates".format(p))
for p in source_plates:
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if value[k] != old[k]:
raise KeyError(
"Key {} has already been set with value {}, new value {}"
.format(key, self[key], value))
except ValueError:
- Create a ticketCreate a ticket
Function get_tool
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_tool(self, name, parameters, version=None):
"""
Gets the tool object from the tool channel(s), and instantiates it using the tool parameters
:param name: The name or stream id for the tool in the tool channel
- Read upRead up
- Create a ticketCreate a ticket
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 find_streams
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_streams(self, **kwargs):
"""
Finds streams with the given meta data values. Useful for debugging purposes.
:param kwargs: The meta data as keyword arguments
- Read upRead up
- Create a ticketCreate a ticket
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 self.header:
values = dict(zip(colnames, map(my_float, elements)))
else:
values = map(float, elements)
instance = StreamInstance(dt, values)
- Create a ticketCreate a ticket
Function check_plate_compatibility
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_plate_compatibility(tool, source_plate, sink_plate):
"""
Checks whether the source and sink plate are compatible given the tool
:param tool: The tool
- Read upRead up
- Create a ticketCreate a ticket
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 next(p.is_root for p in sources[-1].plates):
if len(sink.plates) != 1:
raise IncompatiblePlatesError(
"Multiple sink plates defined. "
"Did you intend a simplification of 2 source plates to a sink plate?")
- Create a ticketCreate a ticket
Function _execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _execute(self, sources, alignment_stream, interval):
# Combine the data, apply the mapping and sort (inefficient!)
results = dict()
for source in sources:
data = source.window(interval, force_calculation=True)
- Read upRead up
- Create a ticketCreate a ticket
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 __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, workflow_id, name, description, owner, online=False, monitor=False):
- Create a ticketCreate a ticket
Function _execute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _execute(self, sources, interval):
time_interval = TimeInterval(MIN_DATE, interval.end)
selector_meta_data = sources[0].window(time_interval, force_calculation=True).last().value
found_source = False
- Read upRead up
- Create a ticketCreate a ticket
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"