krateng/maloja

View on GitHub

Showing 189 of 189 total issues

Function merge_duplicate_tracks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def merge_duplicate_tracks(artist_id=None,dbconn=None):

    affected_track_conditions = []
    if artist_id:
        affected_track_conditions = [DB['trackartists'].c.artist_id == artist_id]
Severity: Minor
Found in maloja/database/sqldb.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 onTabUpdated has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function onTabUpdated(tabId, changeInfo, tab) {


    // still same page?
    //console.log("Update to tab " + tabId + "!")
Severity: Minor
Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.js - 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 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 merge_duplicate_albums has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def merge_duplicate_albums(artist_id=None,dbconn=None):

    affected_album_conditions = []
    if artist_id:
        affected_album_conditions = [DB['albumartists'].c.artist_id == artist_id]
Severity: Minor
Found in maloja/database/sqldb.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 searchresult has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function searchresult() {
    if (this.readyState == 4 && this.status == 200 && document.getElementById("searchinput").value != "" && searches.includes(this)) {
        // any older searches are now rendered irrelevant
        while (searches[0] != this) { searches.splice(0,1) }
        var result = JSON.parse(this.responseText);
Severity: Major
Found in maloja/web/static/js/search.js - About 2 hrs to fix

    Function time_pad has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def time_pad(f,t,full=False):
    
        if f is None or t is None: return f,t
    
        # week handling
    Severity: Minor
    Found in maloja/malojatime.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 cached_wrapper_individual has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def cached_wrapper_individual(inner_func):
    
            def outer_func(set_arg,**kwargs):
                if 'dbconn' in kwargs:
                    conn = kwargs.pop('dbconn')
    Severity: Minor
    Found in maloja/database/dbcache.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

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

            self.rules_replacetitle = {r[1].lower():r[2] for r in rawrules if r[0]=="replacetitle"}
    Severity: Major
    Found in maloja/cleanup.py and 4 other locations - About 1 hr to fix
    maloja/cleanup.py on lines 29..29
    maloja/cleanup.py on lines 30..30
    maloja/cleanup.py on lines 33..33
    maloja/cleanup.py on lines 34..34

    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 47.

    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

    function addEnteredArtist() {
        var newartistfield = document.getElementById("artists");
        var newartist = newartistfield.value.trim();
        newartistfield.value = "";
        if (newartist != "") {
    Severity: Major
    Found in maloja/web/static/js/manualscrobble.js and 1 other location - About 1 hr to fix
    maloja/web/static/js/manualscrobble.js on lines 41..48

    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 70.

    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 5 locations. Consider refactoring.
    Open

            self.rules_fixartists = {r[2].lower():r[1] for r in rawrules if r[0]=="fixartists"}
    Severity: Major
    Found in maloja/cleanup.py and 4 other locations - About 1 hr to fix
    maloja/cleanup.py on lines 28..28
    maloja/cleanup.py on lines 29..29
    maloja/cleanup.py on lines 30..30
    maloja/cleanup.py on lines 34..34

    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 47.

    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 5 locations. Consider refactoring.
    Open

            self.rules_artistintitle = {r[1].lower():r[2] for r in rawrules if r[0]=="artistintitle"}
    Severity: Major
    Found in maloja/cleanup.py and 4 other locations - About 1 hr to fix
    maloja/cleanup.py on lines 28..28
    maloja/cleanup.py on lines 29..29
    maloja/cleanup.py on lines 30..30
    maloja/cleanup.py on lines 33..33

    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 47.

    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

    function addEnteredAlbumartist() {
        var newartistfield = document.getElementById("albumartists");
        var newartist = newartistfield.value.trim();
        newartistfield.value = "";
        if (newartist != "") {
    Severity: Major
    Found in maloja/web/static/js/manualscrobble.js and 1 other location - About 1 hr to fix
    maloja/web/static/js/manualscrobble.js on lines 33..40

    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 70.

    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 5 locations. Consider refactoring.
    Open

            self.rules_replacealbumtitle = {r[1].lower():r[2] for r in rawrules if r[0]=="replacealbumtitle"}
    Severity: Major
    Found in maloja/cleanup.py and 4 other locations - About 1 hr to fix
    maloja/cleanup.py on lines 28..28
    maloja/cleanup.py on lines 30..30
    maloja/cleanup.py on lines 33..33
    maloja/cleanup.py on lines 34..34

    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 47.

    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 5 locations. Consider refactoring.
    Open

            self.rules_replaceartist = {r[1].lower():r[2] for r in rawrules if r[0]=="replaceartist"}
    Severity: Major
    Found in maloja/cleanup.py and 4 other locations - About 1 hr to fix
    maloja/cleanup.py on lines 28..28
    maloja/cleanup.py on lines 29..29
    maloja/cleanup.py on lines 33..33
    maloja/cleanup.py on lines 34..34

    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 47.

    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

    Consider simplifying this complex logical expression.
    Open

        if len(parent_artists) == 0:
            c = [e for e in alltimecharts if e["artist"] == artist]
            position = c[0]["rank"] if len(c) > 0 else None
            others = sqldb.get_associated_artists(artist,dbconn=dbconn)
            result.update({
    Severity: Critical
    Found in maloja/database/__init__.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if reduced:
              pass
          else:
              twk = thisweek()
              tyr = thisyear()
      Severity: Critical
      Found in maloja/database/__init__.py - About 1 hr to fix

        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

        Function submit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def submit(self,pathnodes,keys):
                try:
                    token = self.get_token_from_request_keys(keys)
                except Exception:
                    raise BadAuthException()
        Severity: Minor
        Found in maloja/apis/listenbrainz.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 local_files has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def local_files(artist=None,album=None,track=None):
        
        
            filenames = get_all_possible_filenames(artist=artist,album=album,track=track)
        
        
        Severity: Minor
        Found in maloja/images.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 track_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def track_info(dbconn=None,**keys):
        
            track = keys.get('track')
            if track is None: raise exceptions.MissingEntityParameter()
        
        
        Severity: Minor
        Found in maloja/database/__init__.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

        Severity
        Category
        Status
        Source
        Language