sertansenturk/tomato

View on GitHub

Showing 127 of 287 total issues

Function convertsymbtr2xml has a Cognitive Complexity of 198 (exceeds 5 allowed). Consider refactoring.
Open

    def convertsymbtr2xml(self, verbose=None):
        if verbose is not None:
            self.verbose = verbose

        outkoddict = dict((e, 0) for e in kodlist)

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 symbtr2musicxml.py has 792 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import copy
import os

from lxml import etree

    Function correct_jumps has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        def correct_jumps(self, pitch):
            for i in range(4, len(pitch) - 6):
                if self.are_close(pitch[i - 4][1], pitch[i - 3][1]) and \
                        self.are_close(pitch[i - 3][1], pitch[i - 2][1]) and \
                        self.are_close(pitch[i - 2][1], pitch[i - 1][1]):
    Severity: Minor
    Found in src/tomato/audio/pitchfilter.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

    Function correct_octave_errors_by_chunks has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        def correct_octave_errors_by_chunks(self, pitch):
            pitch_chunks = self.decompose_into_chunks(pitch=pitch)
    
            zero_chunks = []
            zero_ind = []
    Severity: Minor
    Found in src/tomato/audio/pitchfilter.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

    Function decompose_into_chunks has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def decompose_into_chunks(self, pitch):
            """
            decomposes the given pitch track into the chunks.
            """
            pitch_chunks = []
    Severity: Minor
    Found in src/tomato/audio/pitchfilter.py - About 5 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 get_filenames_in_dir has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_filenames_in_dir(dir_name, keyword='*', skip_foldername='',
                                 match_case=True, verbose=False):
            """
            Args:
                dir_name (str): The foldername.
    Severity: Minor
    Found in src/tomato/io.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

    File pitchdistribution.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Copyright 2015 - 2018 Altuğ Karakurt & Sertan Şentürk
    #
    # This file is part of tomato: https://github.com/sertansenturk/tomato/
    #
    # tomato is free software: you can redistribute it and/or modify it under
    Severity: Minor
    Found in src/tomato/audio/pitchdistribution.py - About 4 hrs to fix

      Function _get_theoretical_intervals_to_search has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_theoretical_intervals_to_search(self, makam):
              # Reading dictionary which contains note symbol, theoretical names and
              # their cent values
              note_dict = IO.load_music_data('note')
      
      
      Severity: Minor
      Found in src/tomato/audio/notemodel.py - About 3 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

      SymbTrScore has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SymbTrScore:
          def __init__(self, txtpath, mu2path, symbtrname='', mbid_url='',
                       verbose=None):
              self.txtpath = txtpath  # filepath for the txt score
              self.mu2path = mu2path  # filepath for the mu2 score; used for

        PitchDistribution has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class PitchDistribution:
            def __init__(self, pd_bins, pd_vals, kernel_width=7.5, ref_freq=440.0):
                """-------------------------------------------------------------------
                The main data structure that wraps all the relevant information about a
                pitch distribution.
        Severity: Minor
        Found in src/tomato/audio/pitchdistribution.py - About 3 hrs to fix

          Function fetchsymbtrinfo has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetchsymbtrinfo(self, info):
                  self.sira = info[0]
                  self.kod = info[1]
                  self.nota53 = info[2]
                  self.notaae = info[3]
          Severity: Minor
          Found in src/tomato/symbolic/symbtr/converter/symbtr2musicxml/symbtrnote.py - About 3 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

          Consider simplifying this complex logical expression.
          Open

                          if ((self.are_close(pitch_chunks[i][0][1] / 2.,
                                              pitch_chunks[i - 1][-1][1]) and
                               (pitch_chunks[i][-1][1] / 1.5 >
                                pitch_chunks[i + 1][0][1])) or
                              (self.are_close(med_chunk_i / 2., med_chunk_prev) and
          Severity: Critical
          Found in src/tomato/audio/pitchfilter.py - About 3 hrs to fix

            Function readsymbtrlines has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

                def readsymbtrlines(self):
                    global kodlist, koddict
            
                    # read operation
                    f = open(self.txtpath, encoding='utf-8')

            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 plotter.py has 285 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # Copyright 2016 - 2018 Sertan Şentürk
            #
            # This file is part of tomato: https://github.com/sertansenturk/tomato/
            #
            # tomato is free software: you can redistribute it and/or modify it under
            Severity: Minor
            Found in src/tomato/plotter.py - About 2 hrs to fix

              File pitchfilter.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # Copyright 2014 - 2018 Hasan Sercan Atlı & Sertan Şentürk
              #
              # This file is part of tomato: https://github.com/sertansenturk/tomato/
              #
              # tomato is free software: you can redistribute it and/or modify it under
              Severity: Minor
              Found in src/tomato/audio/pitchfilter.py - About 2 hrs to fix

                Function read_header has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    def read_header(cls, score_file, symbtr_name=None):
                        """
                        Reads the header of the SymbTr-mu2 scores.
                
                        Parameters
                Severity: Minor
                Found in src/tomato/symbolic/symbtr/reader/mu2.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

                File knnclassifier.py has 278 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # Copyright 2015 - 2018 Altuğ Karakurt & Sertan Şentürk
                #
                # This file is part of tomato: https://github.com/sertansenturk/tomato/
                #
                # tomato is free software: you can redistribute it and/or modify it under
                Severity: Minor
                Found in src/tomato/audio/makamtonic/knnclassifier.py - About 2 hrs to fix

                  Function get_note_type has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_note_type(self):
                          # print(self.sira, self.kod, "symbtrnote.get_note_type")
                          temp_pay_payda = float(self.pay) / int(self.payda)
                  
                          temp_undotted = None
                  Severity: Minor
                  Found in src/tomato/symbolic/symbtr/converter/symbtr2musicxml/symbtrnote.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

                  File jointanalyzer.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # Copyright 2016 - 2018 Sertan Şentürk
                  #
                  # This file is part of tomato: https://github.com/sertansenturk/tomato/
                  #
                  # tomato is free software: you can redistribute it and/or modify it under
                  Severity: Minor
                  Found in src/tomato/joint/jointanalyzer.py - About 2 hrs to fix

                    AudioAnalyzer has 23 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class AudioAnalyzer(Analyzer):
                        _inputs = ['makam', 'melodic_progression', 'metadata', 'note_models',
                                   'pitch', 'pitch_class_distribution', 'pitch_distribution',
                                   'pitch_filtered', 'tempo', 'tonic', 'transposition']
                    
                    
                    Severity: Minor
                    Found in src/tomato/audio/audioanalyzer.py - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language