StegSchreck/RatS

View on GitHub

Showing 11 of 23 total issues

File transfer_ratings.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
import argparse
import datetime
import os
import sys
Severity: Minor
Found in transfer_ratings.py - About 2 hrs to fix

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

                    if cookie_accept_button is not None and len(cookie_accept_button) > 1:
                        cookie_accept_button[1].click()
                        time.sleep(2)
    Severity: Major
    Found in RatS/filmaffinity/filmaffinity_site.py and 1 other location - About 1 hr to fix
    RatS/criticker/criticker_site.py on lines 30..32

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

    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 cookie_accept_buttons is not None and len(cookie_accept_buttons) > 0:
                    cookie_accept_buttons[0].click()
                    time.sleep(1)
    Severity: Major
    Found in RatS/criticker/criticker_site.py and 1 other location - About 1 hr to fix
    RatS/filmaffinity/filmaffinity_site.py on lines 37..39

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

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

    def execute_inserting(args, movies: List[Movie], parser: RatingsParser):
        if not args.all_destinations and not args.destination:
            return
        destinations: List[Site] = (
            [inserter for inserter in INSERTERS.keys()]
    Severity: Minor
    Found in transfer_ratings.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

    Consider simplifying this complex logical expression.
    Open

            if args and args.verbose and args.verbose >= 3:
                log_level = "trace"
            elif args and args.verbose and args.verbose == 2:
                log_level = "debug"
            elif args and args.verbose and args.verbose == 1:
    Severity: Major
    Found in RatS/utils/browser_handler.py - About 1 hr to fix

      Function _is_movie_in_search_results has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Confirmed

          def _is_movie_in_search_results(self, movie: Movie, search_results):
              if self._on_search_result_page():
                  for search_result in search_results:
                      if self._is_requested_movie(movie, search_result):
                          return True  # Found
      Severity: Minor
      Found in RatS/filmaffinity/filmaffinity_ratings_inserter.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 _handle_cookie_notice_if_present has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _handle_cookie_notice_if_present(self):
              cookie_notices = self.browser.find_elements(By.ID, "qc-cmp2-container")
              if len(cookie_notices) == 0:
                  return
              cookie_notice = cookie_notices[0]
      Severity: Minor
      Found in RatS/filmaffinity/filmaffinity_site.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 _compare_external_links has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _compare_external_links(
              page_source, movie: Movie, external_url_base: str, site: Site
          ):
              movie_details_page = BeautifulSoup(page_source, "html.parser")
              external_links: List = (
      Severity: Minor
      Found in RatS/trakt/trakt_ratings_inserter.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 from_json has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_json(movie_json):
              if "id" in movie_json.keys():
                  return SiteSpecificMovieData.from_json(movie_json)
              elif "site_data" in movie_json.keys():
                  return Movie(
      Severity: Minor
      Found in RatS/base/movie_entity.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, args):
              login_form_selector = "//form[@name='sign_in']"
              self.LOGIN_USERNAME_SELECTOR = (
                  login_form_selector + "//input[@id='sign_in__username']"
              )
      Severity: Minor
      Found in RatS/allocine/allocine_site.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

      Function _compare_external_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _compare_external_links(
              page_source, movie: Movie, external_url_base: str, site: Site
          ):
              movie_details_page = BeautifulSoup(page_source, "html.parser")
              if movie_details_page.find(class_="ratingstable"):
      Severity: Minor
      Found in RatS/listal/listal_ratings_inserter.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