coursera-dl/coursera-dl

View on GitHub

Showing 71 of 71 total issues

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

def get_lecture_filename(combined_section_lectures_nums,
Severity: Major
Found in coursera/formatting.py - About 50 mins to fix

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

        try:
            os.makedirs(path, mode)
        except OSError as exc:
            if exc.errno == errno.EEXIST and os.path.isdir(path):
    Severity: Minor
    Found in coursera/utils.py and 1 other location - About 50 mins to fix
    fabfile.py on lines 22..25

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

    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

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

        try:
            os.makedirs(path)
        except OSError as exc:
            if exc.errno == errno.EEXIST and os.path.isdir(path):
    Severity: Minor
    Found in fabfile.py and 1 other location - About 50 mins to fix
    coursera/utils.py on lines 189..192

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

    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 get_reply has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_reply(session, url, post=False, data=None, headers=None, quiet=False):
    Severity: Minor
    Found in coursera/network.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if language == "all":
                                  download_all_subtitle = True
                                  break
                              elif language in subtitles_set:
                                  subtitle_set_download.update([language])
      Severity: Major
      Found in coursera/api.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if download_quizzes:
                                    links = course.extract_links_from_programming_immediate_instructions(
                                        lecture.id)
        
        
        Severity: Major
        Found in coursera/extractors.py - About 45 mins to fix

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

              def _get_asset_urls(self, asset_id):
                  """
                  Get list of asset urls and file names. This method may internally
                  use AssetRetriever to extract `asset` element types.
          
          
          Severity: Minor
          Found in coursera/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

          Avoid deeply nested control flow statements.
          Open

                                  if download_quizzes:
                                      links = course.extract_links_from_exam(
                                          lecture.id)
          
          
          Severity: Major
          Found in coursera/extractors.py - About 45 mins to fix

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

                def __init__(self,
            Severity: Minor
            Found in coursera/workflow.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if download_quizzes:
                                          links = course.extract_links_from_quiz(
                                              lecture.id)
              
              
              Severity: Major
              Found in coursera/extractors.py - About 45 mins to fix

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

                    def _extract_peer_assignment_text(self, element_id):
                        """
                        Extract peer assignment text (instructions).
                
                        @param element_id: Element id to extract peer assignment instructions from.
                Severity: Minor
                Found in coursera/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 authenticate_through_netrc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def authenticate_through_netrc(path=None):
                    """
                    Return the tuple user / password given a path for the .netrc file.
                
                    Raises CredentialsError if no valid netrc file is found.
                Severity: Minor
                Found in coursera/credentials.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

                Avoid deeply nested control flow statements.
                Open

                                        if download_notebooks and not self._notebook_downloaded:
                                            logging.warning(
                                                'According to notebooks platform, content will be downloaded first')
                                            links = course.extract_links_from_notebook(
                                                lecture.id)
                Severity: Major
                Found in coursera/extractors.py - About 45 mins to fix

                  Function get_cookies_for_class has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def get_cookies_for_class(session, class_name,
                  Severity: Minor
                  Found in coursera/cookies.py - About 35 mins to fix

                    Function format_combine_number_resource has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def format_combine_number_resource(secnum, lecnum, lecname, title, fmt):
                    Severity: Minor
                    Found in coursera/formatting.py - About 35 mins to fix

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

                          def __init__(self, session, course_id, course_name,
                      Severity: Minor
                      Found in coursera/api.py - About 35 mins to fix

                        Function _iter_modules has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def _iter_modules(modules, class_name, path, ignored_formats, args):
                        Severity: Minor
                        Found in coursera/workflow.py - About 35 mins to fix

                          Function post_page_and_reply has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def post_page_and_reply(session, url, data=None, headers=None, **kwargs):
                          Severity: Minor
                          Found in coursera/network.py - About 35 mins to fix

                            Function _walk_modules has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def _walk_modules(modules, class_name, path, ignored_formats, args):
                            Severity: Minor
                            Found in coursera/workflow.py - About 35 mins to fix

                              Function _handle_resource has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def _handle_resource(self, url, fmt, lecture_filename, callback, last_update):
                              Severity: Minor
                              Found in coursera/workflow.py - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language