krateng/maloja

View on GitHub

Showing 192 of 192 total issues

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

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

function doneEditing() {
    window.getSelection().removeAllRanges();
    var namefield = document.getElementById('main_entity_name');
    namefield.contentEditable = "false";
    newname = namefield.textContent;
Severity: Minor
Found in maloja/web/static/js/edit.js - About 1 hr to fix

    Function onTabUpdated has 37 lines of code (exceeds 25 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 1 hr to fix

      Function removeAssociate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function removeAssociate(element) {
          const parentElement = element.closest('[data-entity_id]');
          var entity_type = parentElement.dataset.entity_type;
          var entity_id = parentElement.dataset.entity_id;
          entity_id = parseInt(entity_id);
      Severity: Minor
      Found in maloja/web/static/js/edit.js - About 1 hr to fix

        Function associate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function associate(element) {
            const parentElement = element.closest('[data-entity_id]');
            var entity_type = parentElement.dataset.entity_type;
            var entity_id = parentElement.dataset.entity_id;
            entity_id = parseInt(entity_id);
        Severity: Minor
        Found in maloja/web/static/js/edit.js - About 1 hr to fix

          Function get_image_album has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_image_album(self,album):
                  self.lock.acquire()
                  try:
                      artists, title = album
                      searchstr = f'release:"{title}"'
          Severity: Minor
          Found in maloja/thirdparty/musicbrainz.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 resolve_image has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def resolve_image(artist_id=None,track_id=None,album_id=None):
              result = get_image_from_cache(artist_id=artist_id,track_id=track_id,album_id=album_id)
              if result is not None:
                  # No need to do anything
                  return
          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 get_image_track has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_image_track(self,track):
                  self.lock.acquire()
                  try:
                      artists, title = track
                      searchstr = f'recording:"{title}"'
          Severity: Minor
          Found in maloja/thirdparty/musicbrainz.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_pulse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_pulse(dbconn=None,**keys):
          
              # amountkeys for pulse and performance aren't really necessary
              # since the amount of entries is completely determined by the time keys
              # but lets just include it in case
          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

          Function post_scrobble has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def post_scrobble(
          Severity: Major
          Found in maloja/apis/native_v1.py - About 1 hr to fix

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

            function toggleDeleteConfirm(element) {
                element.parentElement.parentElement.classList.toggle('active');
                element.parentElement.parentElement.parentElement.classList.toggle('active');
            }
            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 35..38

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

            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 toggleReparseConfirm(element) {
                element.parentElement.parentElement.classList.toggle('active');
                element.parentElement.parentElement.parentElement.classList.toggle('active');
            }
            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 14..17

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

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

            function onInternalMessage(request,sender) {
                // message from settings menu
                if (request.type == "query") {
                    answer = [];
                    for (tabId in tabManagers) {
            Severity: Minor
            Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.js - 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 time_fix has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def time_fix(t):
                if t is None or isinstance(t,MTRangeGeneric): return t
            
                if isinstance(t, str):
                    t = t.lower()
            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 find_good_folder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def find_good_folder(datatype):
                info = directory_info[datatype]
            
                possible_folders = info['possible_folders']
                if os.environ.get("MALOJA_CONTAINER"):
            Severity: Minor
            Found in maloja/pkg_global/conf.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_track_id has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_track_id(trackdict: TrackDict, create_new=True, update_album=False, dbconn=None) -> int | None:
                ntitle = normalize_name(trackdict['title'])
                artist_ids = [get_artist_id(a, create_new=create_new, dbconn=dbconn) for a in trackdict['artists']]
                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 serialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def serialize(obj):
                try:
                    return serialize(obj.hashable())
                except AttributeError:
                    try:
            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 submit_scrobble has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def submit_scrobble(self,pathnodes,keys):
                    key = keys.get("sk")
                    if key is None:
                        raise InvalidSessionKey()
                    client = self.mobile_sessions.get(key)
            Severity: Minor
            Found in maloja/apis/audioscrobbler.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