Showing 16 of 16 total issues
File routes.py
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import collections
import flask
import flask_login
File __init__.py
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
import dataclasses
import datetime
import collections
import typing
File persons.py
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
import dataclasses
import typing
import collections
import numpy as np
Progress
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Progress:
start: datetime.datetime
end: datetime.datetime
points_timeline: timeline.Timeline
status_timeline: timeline.Timeline
Importer
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Importer(importer.BareboneImporter):
def __init__(self, spec):
super().__init__(spec)
self._import_context = "none"
Function _get_event_from_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _get_event_from_data(self, data_dict, name):
time = datetime.datetime.fromisoformat(data_dict["time"])
ret = data.Event(name, data_dict["quantity"] or None, time)
if "value_before" in data_dict:
ret.value_before = data_dict["value_before"]
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
class DemoForm(BaseForm):
issues = wtforms.SelectMultipleField('Issues')
progress = wtforms.FloatField('Progress')
submit = wtforms.SubmitField("Next Day")
- Read upRead up
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
class RedhatComplianceFormEnd(BaseForm):
quarter = wtforms.StringField('Quarter String')
project_next = wtforms.BooleanField('Plan for the Next Quarter')
submit = wtforms.SubmitField("Import Data")
- Read upRead up
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 _get_owner_epic_of
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _get_owner_epic_of(self, assignee, committed):
if not assignee:
assignee = "nobody"
name = f"{PROJECT_NAME}-{assignee}"
if committed:
- 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 process_events
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_events(self, events: typing.Iterable[data.Event]):
if not events:
return
events_from_oldest = sorted(events, key=lambda x: x.time)
events_from_newest = events_from_oldest[::-1]
- 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 _update_class_io_with_extension
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _update_class_io_with_extension(self, new_class, original_class, extension):
if original_class not in persistence.LOADERS or original_class not in persistence.LOADERS:
return
for backend, loader in persistence.LOADERS[original_class].items():
- 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 jira_retry_n
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def jira_retry_n(retries, longest_pause, func, * args, ** kwargs):
Function move_consensus_estimate_to_authoritative
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def move_consensus_estimate_to_authoritative(task_name):
form = flask.current_app.get_final_class("AuthoritativeForm")()
if form.validate_on_submit():
if form.i_kid_you_not.data:
pollster_cons = webdata.AuthoritativePollster()
- 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 _accepted
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _accepted(cls, jira_string, item):
resolution = item.get_field("resolution")
resolution_text = ""
if resolution:
resolution_text = resolution.name
- 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 cost_matrix
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cost_matrix(self):
ret = np.ones((len(self.persons_potential), len(self.cards_by_name)))
ret *= np.inf
for collab_idx, collab_name in enumerate(self.persons_potential):
for task_idx, task_name in enumerate(self.cards_by_name):
- 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 act_on_global_estimate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def act_on_global_estimate(task_name):
r = routers.PollsterRouter()
form = forms.ConsensusForm()
if form.validate_on_submit():
if form.submit.data and form.i_kid_you_not.data:
- 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"