krateng/maloja

View on GitHub

Showing 192 of 192 total issues

Function toggleAssociationIcons has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function toggleAssociationIcons(element) {
    var entity_type = element.dataset.entity_type;
    var entity_id = element.dataset.entity_id;
    entity_id = parseInt(entity_id);

Severity: Minor
Found in maloja/web/static/js/edit.js - About 1 hr to fix

    Function editEntity has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function editEntity() {
    
        var namefield = document.getElementById('main_entity_name');
        try {
            namefield.contentEditable = "plaintext-only"; // not supported by Firefox
    Severity: Minor
    Found in maloja/web/static/js/edit.js - About 1 hr to fix

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

      def get_size_of(obj,counted=None):
          if counted is None:
              counted = set()
          if id(obj) in counted: return 0
          size = sys.getsizeof(obj)
      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

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

      def get_album_id(albumdict: AlbumDict, create_new=True, ignore_albumartists=False, dbconn=None) -> int | None:
          ntitle = normalize_name(albumdict['albumtitle'])
          artist_ids = [get_artist_id(a, dbconn=dbconn) for a in (albumdict.get('artists') or [])]
          artist_ids = list(set(artist_ids))
      
      
      Severity: Minor
      Found in maloja/database/sqldb.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 invalidate_caches has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def invalidate_caches(scrobbletime=None):
      
              cleared, kept = 0, 0
              for k in cache.keys():
                  # VERY BIG TODO: differentiate between None as in 'unlimited timerange' and None as in 'time doesnt matter here'!
      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

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

      def rawscrobble_to_scrobbledict(rawscrobble, fix=True, client=None):
          # raw scrobble to processed info
          scrobbleinfo = {**rawscrobble}
          if fix:
              scrobbleinfo['track_artists'],scrobbleinfo['track_title'] = cla.fullclean(scrobbleinfo['track_artists'],scrobbleinfo['track_title'])
      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

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

              if t.strip().lower() in self.rules_replacetitle:
                  return self.rules_replacetitle[t.strip().lower()]
      Severity: Major
      Found in maloja/cleanup.py and 1 other location - About 1 hr to fix
      maloja/cleanup.py on lines 195..196

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

      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

              if t.strip().lower() in self.rules_replacealbumtitle:
                  return self.rules_replacealbumtitle[t.strip().lower()]
      Severity: Major
      Found in maloja/cleanup.py and 1 other location - About 1 hr to fix
      maloja/cleanup.py on lines 142..143

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

      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 datechange has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function datechange() {
      
          since = document.getElementById("dateselect_from").value;
          to = document.getElementById("dateselect_to").value;
      
      
      Severity: Minor
      Found in maloja/web/static/js/datechange.js - About 1 hr to fix

        Function scrobbleNew has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function scrobbleNew() {
            var artistnodes = document.getElementById("artists_td").getElementsByTagName("span");
            var artists = [];
            for (let node of artistnodes) {
                artists.push(node.textContent);
        Severity: Minor
        Found in maloja/web/static/js/manualscrobble.js - About 1 hr to fix

          Function ranges has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def ranges(since=None,to=None,within=None,timerange=None,step="month",stepn=1,trail=1,max_=None):
          Severity: Major
          Found in maloja/malojatime.py - About 1 hr to fix

            Function get_scrobbles_of_artist has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def get_scrobbles_of_artist(artist,since=None,to=None,resolve_references=True,limit=None,reverse=False,associated=False,dbconn=None):
            Severity: Major
            Found in maloja/database/sqldb.py - About 1 hr to fix

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

                  if (current_stored.indexOf(entity_id) > -1) {
                      element.classList.add('marked_for_associate');
                  } else {
                      element.classList.remove('marked_for_associate');
                  }
              Severity: Major
              Found in maloja/web/static/js/edit.js and 1 other location - About 1 hr to fix
              maloja/web/static/js/edit.js on lines 349..353

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

              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

                  if (current_stored.indexOf(entity_id) > -1) {
                      element.classList.add('marked_for_merge');
                  } else {
                      element.classList.remove('marked_for_merge');
                  }
              Severity: Major
              Found in maloja/web/static/js/edit.js and 1 other location - About 1 hr to fix
              maloja/web/static/js/edit.js on lines 313..317

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

              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 catch_exceptions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def catch_exceptions(func):
                  def protector(*args,**kwargs):
                      try:
                          return func(*args,**kwargs)
                      except Exception as e:
              Severity: Minor
              Found in maloja/apis/native_v1.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 add_scrobbles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def add_scrobbles(scrobbleslist: list[ScrobbleDict], update_album=False, dbconn=None) -> tuple[int, int, int]:
              
                  with SCROBBLE_LOCK:
              
                  #    ops = [
              Severity: Minor
              Found in maloja/database/sqldb.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 backup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def backup(targetfolder=None,include_images=False):
              
                  if targetfolder is None:
                      targetfolder = os.getcwd()
              
              
              Severity: Minor
              Found in maloja/proccontrol/tasks/backup.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 remove_identical has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              def remove_identical(*dicts):
                  #combine multiple dicts
                  keys = FormsDict()
                  for d in dicts:
                      for k in d:
              Severity: Minor
              Found in maloja/malojauri.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 __getattr__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __getattr__(self,name):
                      originalmethod = getattr(database,name)
              
                      def packedmethod(*keys):
                          kwargs = {}
              Severity: Minor
              Found in maloja/database/jinjaview.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

                      if ((this.status >= 200) && (this.status < 300)) {
                          //document.getElementById("checkmark_url").innerHTML = "✔️"
                          //document.getElementById("checkmark_key").innerHTML = "✔️"
                          document.getElementById("serverurl").style.backgroundColor = "lawngreen"
                          document.getElementById("apikey").style.backgroundColor = "lawngreen"
              Severity: Minor
              Found in auxiliary/chromium_scrobbler/maloja-scrobbler/settings.js and 1 other location - About 55 mins to fix
              auxiliary/chromium_scrobbler/maloja-scrobbler/settings.js on lines 136..147

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

              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

              Severity
              Category
              Status
              Source
              Language