Toollabs/video2commons

View on GitHub

Showing 44 of 99 total issues

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

def upload(
    filename, wikifilename, sourceurl, http_host, filedesc, username,
    statuscallback=None, errorcallback=None
):
    """Upload a file from filename to wikifilename."""
Severity: Minor
Found in video2commons/backend/upload/__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 main has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

def main(
Severity: Major
Found in video2commons/backend/worker.py - About 1 hr to fix

    Function ffmpeg_add_audio_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def ffmpeg_add_audio_options(self, options, p):
            """
            Add ffmpeg shell options for audio.
    
            @param options array
    Severity: Minor
    Found in video2commons/backend/encode/transcodejob.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 checkStatusSocket has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            checkStatusSocket: function () {
                if ( window.socket ) {
                    return;
                }
    
    
    Severity: Minor
    Found in video2commons/frontend/static/video2commons.js - About 1 hr to fix

      Function addTask has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              addTask: function ( taskdata ) {
                  if ( !$addTaskDialog ) {
                      $addTaskDialog = $( '<div>' )
                          .html( nunjucksEnv.render( 'addTask.html' ) );
      
      
      Severity: Minor
      Found in video2commons/frontend/static/video2commons.js - About 1 hr to fix

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

        def get(lang):
            """Get the i18n of language lang and output dict."""
            i18nkey = 'i18n:' + lang
            gval = g.get(i18nkey, None)
            if gval:
        Severity: Minor
        Found in video2commons/frontend/i18n.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 upload has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def upload(
        Severity: Major
        Found in video2commons/backend/upload/__init__.py - About 1 hr to fix

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

          def upload_pwb(
          Severity: Major
          Found in video2commons/backend/upload/__init__.py - About 1 hr to fix

            Function download has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def download(
            Severity: Major
            Found in video2commons/backend/download/__init__.py - About 50 mins to fix

              Function encode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def encode(source, origkey, statuscallback=None, errorcallback=None):
                  """Main encode function."""
                  source = os.path.abspath(source)
                  preserve = {'video': False, 'audio': False}
              
              
              Severity: Minor
              Found in video2commons/backend/encode/__init__.py - About 45 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 upload_ss has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def upload_ss(
              Severity: Minor
              Found in video2commons/backend/upload/__init__.py - About 45 mins to fix

                Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(
                Severity: Minor
                Found in video2commons/backend/encode/transcodejob.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if duration_match:
                                              duration = time_to_seconds(duration_match.group(1))
                                      else:
                  Severity: Major
                  Found in video2commons/backend/encode/transcodejob.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if position_match:
                                                position = time_to_seconds(position_match.group(1))
                                                if duration and position:
                                                    newpercentage = min(int(
                                                        math.floor(100 * position / duration)
                    Severity: Major
                    Found in video2commons/backend/encode/transcodejob.py - About 45 mins to fix

                      Function list_formats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def list_formats():
                          """List the possible convert formats from a given audio/video pair."""
                          formats = []
                          prefer = ''
                          video = _boolize(request.form['video'])
                      Severity: Minor
                      Found in video2commons/frontend/api.py - About 45 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 subtitles has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def subtitles(
                      Severity: Minor
                      Found in video2commons/backend/subtitles/__init__.py - About 35 mins to fix

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

                            def open_session(self, app, request):
                                """Get session from Redis / start a new session."""
                                sid = request.cookies.get(app.session_cookie_name)
                                if sid:
                                    val = self.redis.get(self.prefix + sid)
                        Severity: Minor
                        Found in video2commons/frontend/redisession.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 save_session has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def save_session(self, app, session, response):
                                """Save session to Redis."""
                                domain = self.get_cookie_domain(app)
                                path = url_for('main', _external=False)
                        
                        
                        Severity: Minor
                        Found in video2commons/frontend/redisession.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 handle_chunked has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def handle_chunked(f, permpath, content_range):
                            try:
                                content_range = RE_CONTENT_RANGE.match(content_range)
                                assert content_range, 'Invalid content range!'
                        
                        
                        Severity: Minor
                        Found in video2commons/frontend/upload.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 getlanguage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def getlanguage():
                            """Get the user language."""
                            gval = g.get('language', None)
                            if gval:
                                return gval
                        Severity: Minor
                        Found in video2commons/frontend/i18n.py - About 25 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

                        Severity
                        Category
                        Status
                        Source
                        Language