teamdigitale/italia-app

View on GitHub
scripts/check_urls/check_urls.py

Summary

Maintainability
B
5 hrs
Test Coverage

File check_urls.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import re
import ssl
from multiprocessing import Manager, Pool, cpu_count
from os.path import abspath, basename, dirname, join
Severity: Minor
Found in scripts/check_urls/check_urls.py - About 2 hrs to fix

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

    def read_file(files, black_list_url):
        """
        Reads the collection of files passed as parameter and returns the set of uris found inside all the files
        :param files: an iterable of file paths
        :param black_list_url: a set of urls to exclude from scanning
    Severity: Minor
    Found in scripts/check_urls/check_urls.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 scan_directory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan_directory(path, file_black_list, black_list_url, ext_set={'*.ts*'}):
        """
          Scan the chosen directory, and the sub-directories and returns the execution of read_file from the found collection of files
          :param path: directory to scan
          :param file_black_list: a set of files to exclude from scanning
    Severity: Minor
    Found in scripts/check_urls/check_urls.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

    Avoid too many return statements within this function.
    Open

            return "Timeout - " + str(e)
    Severity: Major
    Found in scripts/check_urls/check_urls.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return "General Error - " + str(e)
      Severity: Major
      Found in scripts/check_urls/check_urls.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return str(e)
        Severity: Major
        Found in scripts/check_urls/check_urls.py - About 30 mins to fix

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

          def test_availability(uri_to_test):
              """
                      Tests the uri passed as argument making an http get request.
                      If it causes an exception or an error code the uri will be returned
                      :param uri: the uri to test
          Severity: Minor
          Found in scripts/check_urls/check_urls.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

          There are no issues that match your filters.

          Category
          Status