krateng/maloja

View on GitHub
maloja/proccontrol/tasks/import_scrobbles.py

Summary

Maintainability
D
2 days
Test Coverage

Function parse_spotify has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

def parse_spotify(inputf):
    pth = os.path
    # use absolute paths internally for peace of mind. just change representation for console output
    inputf = pth.abspath(inputf)
    inputfolder = pth.dirname(inputf)
Severity: Minor
Found in maloja/proccontrol/tasks/import_scrobbles.py - About 6 hrs 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

File import_scrobbles.py has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os, datetime, re
import json, csv

from doreah.io import col, ask, prompt

Severity: Minor
Found in maloja/proccontrol/tasks/import_scrobbles.py - About 5 hrs to fix

    Function import_scrobbles has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def import_scrobbles(inputf):
    
        from ...database.sqldb import add_scrobbles
    
        result = {
    Severity: Minor
    Found in maloja/proccontrol/tasks/import_scrobbles.py - About 4 hrs 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 parse_spotify_lite has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_spotify_lite(inputf):
        pth = os.path
        # use absolute paths internally for peace of mind. just change representation for console output
        inputf = pth.abspath(inputf)
        inputfolder = pth.dirname(inputf)
    Severity: Minor
    Found in maloja/proccontrol/tasks/import_scrobbles.py - About 2 hrs 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 parse_spotify_lite_legacy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_spotify_lite_legacy(inputf):
        pth = os.path
        # use absolute paths internally for peace of mind. just change representation for console output
        inputf = pth.abspath(inputf)
        inputfolder = pth.dirname(inputf)
    Severity: Minor
    Found in maloja/proccontrol/tasks/import_scrobbles.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 parse_rockbox has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_rockbox(inputf):
        with open(inputf,'r') as inputfd:
            for line in inputfd.readlines():
                if line == "#TZ/UNKNOWN":
                    use_local_time = True
    Severity: Minor
    Found in maloja/proccontrol/tasks/import_scrobbles.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

    Avoid deeply nested control flow statements.
    Open

                            if (abs(scr[0] - timestamp) < 30) and scr[1:] == scrobble_describe[1:]:
                                yield ('UNCERTAIN_SKIP',None,f"{entry} might be a duplicate, skipping...")
                                found_similar = True
                                break
                        else:
    Severity: Major
    Found in maloja/proccontrol/tasks/import_scrobbles.py - About 45 mins to fix

      Function parse_maloja has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_maloja(inputf):
      
          with open(inputf,'r') as inputfd:
              data = json.load(inputfd)
      
      
      Severity: Minor
      Found in maloja/proccontrol/tasks/import_scrobbles.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 parse_lastfm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_lastfm(inputf):
      
          with open(inputf,'r',newline='') as inputfd:
              reader = csv.reader(inputfd)
      
      
      Severity: Minor
      Found in maloja/proccontrol/tasks/import_scrobbles.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

      There are no issues that match your filters.

      Category
      Status