matejak/estimagus

View on GitHub

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
Severity: Minor
Found in estimage/webapp/main/routes.py - About 3 hrs to fix

    File __init__.py has 298 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import dataclasses
    import datetime
    import collections
    import typing
    
    
    Severity: Minor
    Found in estimage/plugins/jira/__init__.py - About 3 hrs to fix

      File persons.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import dataclasses
      import typing
      import collections
      
      import numpy as np
      Severity: Minor
      Found in estimage/persons.py - About 2 hrs to fix

        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
        Severity: Minor
        Found in estimage/history/progress.py - About 2 hrs to fix

          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"
          Severity: Minor
          Found in estimage/plugins/jira/__init__.py - About 2 hrs to fix

            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"]
            Severity: Minor
            Found in estimage/persistence/event/ini.py - About 55 mins to fix

            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")
            Severity: Minor
            Found in estimage/plugins/demo/forms.py and 1 other location - About 55 mins to fix
            estimage/plugins/redhat_compliance/forms.py on lines 7..10

            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

            Further Reading

            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")
            Severity: Minor
            Found in estimage/plugins/redhat_compliance/forms.py and 1 other location - About 55 mins to fix
            estimage/plugins/demo/forms.py on lines 6..9

            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

            Further Reading

            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:
            Severity: Minor
            Found in estimage/plugins/crypto/__init__.py - About 45 mins to fix

            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]
            Severity: Minor
            Found in estimage/history/timeline.py - About 45 mins to fix

            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():
            Severity: Minor
            Found in estimage/__init__.py - About 45 mins to fix

            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):
            Severity: Minor
            Found in estimage/plugins/jira/importer.py - About 35 mins to fix

              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()
              Severity: Minor
              Found in estimage/webapp/main/routes.py - About 35 mins to fix

              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
              Severity: Minor
              Found in estimage/plugins/crypto/__init__.py - About 35 mins to fix

              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):
              Severity: Minor
              Found in estimage/persons.py - About 25 mins to fix

              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:
              Severity: Minor
              Found in estimage/webapp/main/routes.py - About 25 mins to fix

              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

              Severity
              Category
              Status
              Source
              Language