podusowski/spartan

View on GitHub

Showing 9 of 203 total issues

Function week_range has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def week_range(number=None, end=None, start=timezone.now()):
    if number is None and end is None:
        raise AttributeError("number or end parameter must be provided")

    week_start = arrow.get(start).floor('week').datetime
Severity: Minor
Found in training/dates.py - About 1 hr 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 setGlobalSettings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

spartan.charts.setGlobalSettings = function()
{
    Chart.defaults.global.maintainAspectRatio = false;

    Chart.defaults.global.elements.rectangle.borderColor = 'rgba(207, 74, 8, 0.8)';
Severity: Minor
Found in training/static/training/js/charts.js - About 1 hr to fix

    Function month_range has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def month_range(number=None, end=None, start=None):
        if start is None:
            start = timezone.now()
    
        week_start = arrow.get(start).floor('month').datetime
    Severity: Minor
    Found in training/dates.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

    Function all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def all(self, now=timezone.now()) -> List[Goal]:
            volumes = {f.name: f.volume for f in self.statistics.favourites_this_month()}
    
            def calculate_forecast(percent):
                date_progress = dates.this_month(now=now).progress(now)
    Severity: Minor
    Found in statistics/goals.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 save_gpx has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def save_gpx(user, content):
        logging.debug("saving gpx")
    
        parsed = gpxpy.parse(content)
    
    
    Severity: Minor
    Found in activities/gps/gpx.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, volumes=None):
            self.volumes = {}
            if volumes is not None:
                for volume in volumes:
                    if volume.type in self.volumes:
    Severity: Minor
    Found in training/units.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 formatTime has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    spartan.utils.formatTime = function(ms) {
        if (ms < 0) {
            return "--";
        }
    
    
    Severity: Minor
    Found in training/static/training/js/utils.js - 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 synchronize_endomondo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def synchronize_endomondo(user, max_results=None):
        key = models.AuthKeys.objects.get(user=user, name="endomondo")
        endomondo = endoapi.endomondo.Endomondo(token=key.key)
    
        newest, oldest = _endomondo_time_bounds(user)
    Severity: Minor
    Found in activities/gps/endomondo.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 first_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def first_time(user, excercise_name):
        for app_statistics in registry.modules('local_statistics'):
            if hasattr(app_statistics, 'first_time'):
                stats = app_statistics.first_time(user, excercise_name)
                if stats:
    Severity: Minor
    Found in statistics/statistics.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