SpamExperts/OrangeAssassin

View on GitHub

Showing 287 of 802 total issues

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

    def _update_mime_ma_non_text(self, msg, part):
        if not self.get_local(msg, "mime_ma_non_text"):
            for ma_part in part.get_payload():
                if(ma_part.get_content_maintype() != "text" and
                   ma_part.get_content_type not in (
Severity: Minor
Found in oa/plugins/mime_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

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

    def check_bayes(self, msg, min_score, max_score=float('inf'), target=None):
        """Check the message against the active Bayes classifier."""
        min_score = float(min_score)
        max_score = float(max_score)
        if not self["use_learner"]:
Severity: Minor
Found in oa/plugins/bayes.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 pdf_match_details has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def pdf_match_details(self, msg, detail, regex, target=None):
        """Match if the detail match with any of the PDF files in the
        message.

        :param detail: author, creator, created, modified, producer, title
Severity: Minor
Found in oa/plugins/pdf_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

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

    def helo_ip_mismatch(self, msg, option=None, target=None):
        """Check untrusted relays and verify if helo and ip are different
        but have the same /24 netmask"""
        for relay in msg.untrusted_relays:
            if not self._check_helo(relay):
Severity: Minor
Found in oa/plugins/relay_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

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

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

def dbi_to_alchemy(dsn, user, password):
    """Convert perl DBI setting to SQLAlchemy settings."""
    dummy, driver, connection = dsn.split(":", 2)
    if driver.lower() == "mysql":
        driver = "mysql+pymysql"
Severity: Minor
Found in oa/plugins/base.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 subject_is_all_caps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def subject_is_all_caps(self, msg, target=None):
        """Checks if the subject is all capital letters.

        This eval rule ignore short subjects, one word subject and
        the prepended notations. (E.g. ``Re:``)
Severity: Minor
Found in oa/plugins/header_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

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

    def plugin_tags_mysql(self, msg, origin_ip, addr, signed_by, score, factor):
        try:
            conn = pymysql.connect(host=self.engine["hostname"], port=3306,
                                   user=self.engine["user"],
                                   passwd=self.engine["password"],
Severity: Minor
Found in oa/plugins/awl.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 parsed_metadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def parsed_metadata(self, msg):
        if self.get_global("ignore_received_spf_header"):
            # The plugin will ignore the spf headers and will perform
            # SPF check by itself by querying the dns
            if msg.get_decoded_header("received"):
Severity: Minor
Found in oa/plugins/spf.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 get_rule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_rule(cls, name, data):
        kwargs = cls.get_rule_kwargs(data)
        value = data["value"].strip()

        if "=~" in value:
Severity: Minor
Found in oa/rules/header.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 get_adjusted_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_adjusted_message(self, msg, header_only=False):
        """Get message adjusted by the rules."""
        spam = msg.score >= self.conf["required_score"]
        if not spam or header_only or self.conf["report_safe"] == 0:
            newmsg = email.message_from_string(msg.raw_msg)
Severity: Minor
Found in oa/rules/ruleset.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 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/spf.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 _parse_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _parse_message(self):
        for header in self.received_headers:
            if not self.check_for_skip(header):
                rdns = self.get_rdns(header)
                ip = self.get_ip(header)
Severity: Minor
Found in oa/received_parser.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 get_ip has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_ip(header):
        """Parsing the relay ip address from Received header

        :param header: The received header without the 'from ' at the begin
        :return: ip address if is found if not it returns an empty string
Severity: Minor
Found in oa/received_parser.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 match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def match(self, msg):
        for header_name in self._headers or ():
            for value in msg.get_decoded_header(header_name):
                if self._pattern.match(value):
                    return True
Severity: Minor
Found in oa/rules/header.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

    Avoid too many return statements within this function.
    Open

            return False
    Severity: Major
    Found in oa/plugins/mime_eval.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return False
      Severity: Major
      Found in oa/plugins/auto_learn_threshold.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return False
        Severity: Major
        Found in oa/plugins/dns_eval.py - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language