Nekmo/dirhunt

View on GitHub

Showing 48 of 48 total issues

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

        path += (';' if self.urlparsed[3] else '') + self.urlparsed[3]
Severity: Major
Found in dirhunt/url.py and 3 other locations - About 45 mins to fix
dirhunt/url.py on lines 83..83
dirhunt/url.py on lines 84..84
dirhunt/url.py on lines 141..141

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

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

    def get_data(self):
        session = self.sessions.get_session()
        try:
            resp = session.get(self.url.url, stream=True, timeout=self.timeout, allow_redirects=False)
        except RequestException:
Severity: Minor
Found in dirhunt/url_info.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 Fore.MAGENTA
Severity: Major
Found in dirhunt/colors.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return Fore.LIGHTMAGENTA_EX
    Severity: Major
    Found in dirhunt/colors.py - About 30 mins to fix

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

      def status_code_colors(status_code):
          if 100 <= status_code < 200:
              return Fore.WHITE
          elif  200 == status_code:
              return Fore.LIGHTGREEN_EX
      Severity: Minor
      Found in dirhunt/colors.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 search_index_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def search_index_files(self):
              if self.crawler_url.type not in ['directory', None]:
                  return
              crawler = self.crawler_url.crawler
              for index_file in INDEX_FILES:
      Severity: Minor
      Found in dirhunt/processors.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 set_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_type(self, content_type):
              from dirhunt.processors import INDEX_FILES
              if not self.type and not (content_type or '').startswith('text/html'):
                  self.type = 'asset'
              if not self.type and (content_type or '').startswith('text/html') and self.url.name in INDEX_FILES:
      Severity: Minor
      Found in dirhunt/crawler_url.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 force_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def force_url(url):
          """Transform domain.com to http://domain.com
      
          Try the most common protocols until you get an answer.
          Check the destination url in case the server is
      Severity: Minor
      Found in dirhunt/utils.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