SpamExperts/OrangeAssassin

View on GitHub
oa/plugins/wlbl_eval.py

Summary

Maintainability
F
4 days
Test Coverage

File wlbl_eval.py has 404 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" WLBLEval plugin."""
from __future__ import absolute_import
from builtins import str
import re
from collections import defaultdict
Severity: Minor
Found in oa/plugins/wlbl_eval.py - About 5 hrs to fix

    WLBLEvalPlugin has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class WLBLEvalPlugin(oa.plugins.base.BasePlugin):
        eval_rules = ("check_from_in_whitelist", "check_to_in_whitelist",
                      "check_from_in_blacklist", "check_to_in_blacklist",
                      "check_from_in_list", "check_to_in_all_spam",
                      "check_to_in_list", "check_mailfrom_matches_rcvd",
    Severity: Minor
    Found in oa/plugins/wlbl_eval.py - About 4 hrs to fix

      Cyclomatic complexity is too high in method check_whitelist_rcvd. (8)
      Open

          def check_whitelist_rcvd(self, msg, list_name, address):
              """Look up address and trusted relays in a whitelist with rcvd
              """
              if len(msg.untrusted_relays) + len(msg.trusted_relays) == 0:
                  return 0
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method base_domain. (7)
      Open

          def base_domain(self, address):
              """ Parse the address in order to extract the domain and the TLD
              """
              domain = address
              parts = domain.split('.')
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method parse_list. (6)
      Open

          def parse_list(self, list_name):
              parsed_list = []
              characters = ["?", "@", ".", "*@"]
              for addr in self[list_name]:
                  if len([e for e in characters if e in addr]):
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method check_rcvd. (6)
      Open

          def check_rcvd(self, domain, relays):
              """Check if it is a match by IP address or is a subnet.
              If is not a valid IP address, try to match by rdns
              """
              match = -1
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method check_in_list. (6)
      Open

          def check_in_list(self, msg, addresses, list_name):
              """Check if addresses match the regexes from list_name and modify
              "from_in_whitelist" msg value based on the list name
              """
              param = "from_in_whitelist"
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method check_mailfrom_matches_rcvd. (6)
      Open

          def check_mailfrom_matches_rcvd(self, msg, target=None):
              """ If there is an EnvelopeFrom address, get it's domain.
              If there are untrusted relays, get the first one,
              else if there are trusted relays get them all.
              For each non empty relay rdns verify if the last part
      Severity: Minor
      Found in oa/plugins/wlbl_eval.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function check_whitelist_rcvd has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_whitelist_rcvd(self, msg, list_name, address):
              """Look up address and trusted relays in a whitelist with rcvd
              """
              if len(msg.untrusted_relays) + len(msg.trusted_relays) == 0:
                  return 0
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 parse_delist_uri has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_delist_uri(self):
              """Parse 'delist_uri_host'. If there is no list name,
                  then apply for all lists.
              """
              parsed_list = defaultdict(list)
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 parse_input has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_input(self, list_name):
              """Parse the list into a dictionary with the regex as key and the
              domain as value.
              """
              parsed_list = defaultdict(list)
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 check_in_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_in_list(self, msg, addresses, list_name):
              """Check if addresses match the regexes from list_name and modify
              "from_in_whitelist" msg value based on the list name
              """
              param = "from_in_whitelist"
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 check_rcvd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_rcvd(self, domain, relays):
              """Check if it is a match by IP address or is a subnet.
              If is not a valid IP address, try to match by rdns
              """
              match = -1
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 check_uri_host_listed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_uri_host_listed(self, msg, list_name, target=None):
              """Check if the message has URIs that are listed
              in the specified hostname
              """
              parsed_list = 'parsed_enlist_uri_host'
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 check_mailfrom_matches_rcvd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_mailfrom_matches_rcvd(self, msg, target=None):
              """ If there is an EnvelopeFrom address, get it's domain.
              If there are untrusted relays, get the first one,
              else if there are trusted relays get them all.
              For each non empty relay rdns verify if the last part
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 parse_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_list(self, list_name):
              parsed_list = []
              characters = ["?", "@", ".", "*@"]
              for addr in self[list_name]:
                  if len([e for e in characters if e in addr]):
      Severity: Minor
      Found in oa/plugins/wlbl_eval.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 ".".join(parts[-2:])
      Severity: Major
      Found in oa/plugins/wlbl_eval.py - About 30 mins to fix

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

            def check_found_forged(self, address, found_forged):
                """If it is forged, check the address in list """
                if found_forged:
                    wlist = self['parsed_whitelist_allow_relays']
                    for addr in wlist:
        Severity: Minor
        Found in oa/plugins/wlbl_eval.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 check_address_in_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_address_in_list(self, addresses, list_name):
                """Check if addresses match the regexes from list_name.
                """
                for address in addresses:
                    for regex in self[list_name]:
        Severity: Minor
        Found in oa/plugins/wlbl_eval.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

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

            def parse_list(self, list_name):
                parsed_list = []
                characters = ["?", "@", ".", "*@"]
                for addr in self[list_name]:
                    if len([e for e in characters if e in addr]):
        Severity: Major
        Found in oa/plugins/wlbl_eval.py and 2 other locations - About 7 hrs to fix
        oa/plugins/bayes.py on lines 560..571
        oa/plugins/spf.py on lines 148..159

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

        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

            def check_in_TL_TLDS(self, address):
                if address in self["util_rb_tld"]:
                    return True
                if address in self["util_rb_2tld"]:
                    return True
        Severity: Major
        Found in oa/plugins/wlbl_eval.py and 1 other location - About 3 hrs to fix
        oa/plugins/header_eval.py on lines 680..687

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

        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

            def check_address_in_list(self, addresses, list_name):
                """Check if addresses match the regexes from list_name.
                """
                for address in addresses:
                    for regex in self[list_name]:
        Severity: Major
        Found in oa/plugins/wlbl_eval.py and 1 other location - About 1 hr to fix
        oa/plugins/bayes.py on lines 573..580

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

        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 self.check_in_TL_TLDS(".".join(parts[-2:])):
                    return ".".join(parts[-3:])
        Severity: Minor
        Found in oa/plugins/wlbl_eval.py and 1 other location - About 55 mins to fix
        oa/plugins/wlbl_eval.py on lines 255..256

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

        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 self.check_in_TL_TLDS(".".join(parts[-3:])):
                    return ".".join(parts[-4:])
        Severity: Minor
        Found in oa/plugins/wlbl_eval.py and 1 other location - About 55 mins to fix
        oa/plugins/wlbl_eval.py on lines 257..258

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

        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

        Block comment should start with '# '
        Open

        #TL_TLDS = ['com', 'co.uk', 'multi.surbl.org']
        Severity: Minor
        Found in oa/plugins/wlbl_eval.py by pep8

        Separate inline comments by at least two spaces.

        An inline comment is a comment on the same line as a statement.
        Inline comments should be separated by at least two spaces from the
        statement. They should start with a # and a single space.
        
        Each line of a block comment starts with a # and a single space
        (unless it is indented text inside the comment).
        
        Okay: x = x + 1  # Increment x
        Okay: x = x + 1    # Increment x
        Okay: # Block comment
        E261: x = x + 1 # Increment x
        E262: x = x + 1  #Increment x
        E262: x = x + 1  #  Increment x
        E265: #Block comment
        E266: ### Block comment

        Missing whitespace around operator
        Open

                        swl_ip =str(wl_ip)
        Severity: Minor
        Found in oa/plugins/wlbl_eval.py by pep8

        Surround operators with a single space on either side.

        - Always surround these binary operators with a single space on
          either side: assignment (=), augmented assignment (+=, -= etc.),
          comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
          Booleans (and, or, not).
        
        - If operators with different priorities are used, consider adding
          whitespace around the operators with the lowest priorities.
        
        Okay: i = i + 1
        Okay: submitted += 1
        Okay: x = x * 2 - 1
        Okay: hypot2 = x * x + y * y
        Okay: c = (a + b) * (a - b)
        Okay: foo(bar, key='word', *args, **kwargs)
        Okay: alpha[:-i]
        
        E225: i=i+1
        E225: submitted +=1
        E225: x = x /2 - 1
        E225: z = x **y
        E225: z = 1and 1
        E226: c = (a+b) * (a-b)
        E226: hypot2 = x*x + y*y
        E227: c = a|b
        E228: msg = fmt%(errno, errmsg)

        Line too long (83 > 79 characters)
        Open

                        address = re.escape(addr).replace(r"\*", ".*").replace(r"\?", ".?")
        Severity: Minor
        Found in oa/plugins/wlbl_eval.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        There are no issues that match your filters.

        Category
        Status