SpamExperts/OrangeAssassin

View on GitHub

Showing 287 of 802 total issues

File bayes.py has 960 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Bayes - determine spam likelihood using a Bayesian classifier.

This is a Bayesian-style probabilistic classifier, using an algorithm
based on the one detailed in Paul Graham's "A Plan For Spam" paper at:

Severity: Major
Found in oa/plugins/bayes.py - About 2 days to fix

    File header_eval.py has 728 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Expose some eval rules that do checks on the headers."""
    
    from __future__ import absolute_import
    from __future__ import division
    
    
    Severity: Major
    Found in oa/plugins/header_eval.py - About 1 day to fix

      Function _handle_line has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
      Open

          def _handle_line(self, filename, line, line_no, _depth=0):
              """Handles a single line."""
              try:
                  line = line.decode("iso-8859-1").strip()
              except UnicodeDecodeError as e:
      Severity: Minor
      Found in oa/rules/parser.py - About 1 day 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

      File received_parser.py has 535 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Parser for Received headers
      It extracts the following metadata:
      :rdns
      :ip
      Severity: Major
      Found in oa/received_parser.py - About 1 day to fix

        Function _tokenise_line has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
        Open

            def _tokenise_line(self, line, tokprefix, region):
                # Include quotes, .'s and -'s for URIs, and [$,]'s for Nigerian-scam
                # strings, and ISO-8859-15 alphas. Do not split on @'s; better
                # results keeping it.
                # Some useful tokens: "$31,000,000" "www.clock-speed.net" "f*ck" "Hits!"
        Severity: Minor
        Found in oa/plugins/bayes.py - About 7 hrs 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

        File message.py has 492 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Internal representation of email messages."""
        
        from builtins import str
        from builtins import set
        from builtins import list
        Severity: Minor
        Found in oa/message.py - About 7 hrs to fix

          Function _parse_relays has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_relays(self, relays):
                  """Walks though a relays list to extract
                  [un]trusted/internal/external relays"""
                  is_trusted = True
                  is_internal = True
          Severity: Minor
          Found in oa/message.py - About 5 hrs 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

          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

            BayesPlugin has 38 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class BayesPlugin(oa.plugins.base.BasePlugin):
                """Implement a somewhat Bayesian plug-in."""
            
                learn_caller_will_untie = False
                learn_no_relearn = False
            Severity: Minor
            Found in oa/plugins/bayes.py - About 5 hrs to fix

              File free_mail.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """FreeMail Plugin
              
              The FreeMail plugin checks the headers for indication that the sender's
              domain is that of a site offering free email services.
              """
              Severity: Minor
              Found in oa/plugins/free_mail.py - About 4 hrs to fix

                HeaderEval has 37 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class HeaderEval(oa.plugins.base.BasePlugin):
                    hotmail_addr_with_forged_hotmail_received = 0
                    hotmail_addr_but_no_hotmail_received = 0
                    tocc_sorted_count = 7
                    tocc_similar_count = 5
                Severity: Minor
                Found in oa/plugins/header_eval.py - About 4 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

                    Function check_spf_received_header has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def check_spf_received_header(self, received_spf_headers):
                            for spf_header in received_spf_headers:
                                match = RECEIVED_RE.match(spf_header)
                                if not match:
                                    self.ctxt.log.debug("PLUGIN::SPF: invalid Received_SPF "
                    Severity: Minor
                    Found in oa/plugins/spf.py - About 4 hrs 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_for_forged_received has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _check_for_forged_received(self, msg):
                            mismatch_from = 0
                            mismatch_ip_helo = 0
                            hostname_re = Regex(r"^\w+(?:[\w.-]+\.)+\w+$")
                            ip_re = Regex(r"^(\d+\.\d+)\.\d+\.\d+")
                    Severity: Minor
                    Found in oa/plugins/relay_eval.py - About 4 hrs 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_rdns has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_rdns(header):
                            """Parsing rdns from Received header
                    
                            :param header: The received header without the 'from ' at the begin
                            :return: rdns if is found if not it returns an empty string
                    Severity: Minor
                    Found in oa/received_parser.py - About 4 hrs 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

                    File mime_eval.py has 343 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    """Expose some eval rules that do checks on the MIME headers."""
                    
                    import re
                    
                    import oa.locales
                    Severity: Minor
                    Found in oa/plugins/mime_eval.py - About 4 hrs to fix

                      Function main has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def main():
                          options = parse_arguments(sys.argv[1:])
                          oa.config.LAZY_MODE = not options.lazy_mode
                          logger = oa.config.setup_logging("oa-logger", debug=options.debug)
                          config_files = oa.config.get_config_files(options.configpath,
                      Severity: Minor
                      Found in scripts/match.py - About 4 hrs 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_illegal_chars has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def check_illegal_chars(self, msg, header, ratio, count, target=None):
                              """look for 8-bit and other illegal characters that should be MIME
                              encoded, these might want to exempt languages that do not use
                              Latin-based alphabets, but only if the user wants it that way
                              """
                      Severity: Minor
                      Found in oa/plugins/header_eval.py - About 4 hrs 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_dkim_adsp has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def check_dkim_adsp(self, msg, adsp_char="", domains_list=None,
                                              target=None):
                              """Check Author Domain Signing Practices from any author domains or
                              from specified author domains only when there is no valid signature. """
                              if not self.dkim_checked_signature:
                      Severity: Minor
                      Found in oa/plugins/dkim.py - About 4 hrs 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_for_to_in_subject has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def check_for_to_in_subject(self, msg, test, target=None):
                              """
                              Check if to address is in Subject field.
                      
                              If it is called with 'address', check if full address is in subject,
                      Severity: Minor
                      Found in oa/plugins/header_eval.py - About 3 hrs 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