mobiledefense/google_safe_browsing

View on GitHub

Showing 12 of 14 total issues

Method receive_data has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    def self.receive_data(url, list)
      urls = url.split(',')
      url = urls[0]
      mac = urls[1]

Severity: Minor
Found in lib/google_safe_browsing/response_helper.rb - 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

Method receive_data has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.receive_data(url, list)
      urls = url.split(',')
      url = urls[0]
      mac = urls[1]

Severity: Major
Found in lib/google_safe_browsing/response_helper.rb - About 4 hrs to fix

    Method parse_data_response has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.parse_data_response(response)
          ret = {}
    
          ret[:lists] = []
          ret[:data_urls] = {}
    Severity: Minor
    Found in lib/google_safe_browsing/response_helper.rb - About 1 hr to fix

      Method generate_path_strings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.generate_path_strings(raw_path)
            return ['/', ''] if raw_path == ''
      
            path_split = raw_path.split('?')
            path = path_split[0] || ''
      Severity: Minor
      Found in lib/google_safe_browsing/canonicalize.rb - 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

      Method fix_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.fix_path(path)
            # remove leading slash
            path = path[1..-1] if path[0..0] == '/'
      
            preserve_trailing_slash = (path[-1..-1] == '/')
      Severity: Minor
      Found in lib/google_safe_browsing/canonicalize.rb - 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

      Method squish_number_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.squish_number_list(chunks)
            num_strings = []
            streak_begin = last_num = chunks.shift
      
            chunks.each do |c|
      Severity: Minor
      Found in lib/google_safe_browsing/chunk_helper.rb - 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

      Method with_keys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.with_keys(uri)
              begin
                get_keys unless GoogleSafeBrowsing.config.have_keys?
                response = yield uri
              end while self.please_rekey?(response.body)
      Severity: Minor
      Found in lib/google_safe_browsing/http_helper.rb - 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

      Method build_chunk_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.build_chunk_list(*lists)
            lists = if lists.any?
                      lists.to_a
                    else
                      GoogleSafeBrowsing.config.current_lists
      Severity: Minor
      Found in lib/google_safe_browsing/chunk_helper.rb - 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

      Method fix_host has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.fix_host(host)
            # remove leading and trailing dots, multiple dots to one
            host.gsub!(/\A\.+|\.+\Z/, '')
            host.gsub!(/\.+/, '.')
      
      
      Severity: Minor
      Found in lib/google_safe_browsing/canonicalize.rb - 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

      Avoid deeply nested control flow statements.
      Open

                        if count > 0
                          count.times do |i|
                            sub_attrs[:add_chunk_number] = BinaryHelper.unpack_add_chunk_num(BinaryHelper.read_bytes_from(chunk_iterator, 4))
                            sub_attrs[:prefix] = BinaryHelper.read_bytes_as_hex(chunk_iterator, line_actions[:hash_length])
                            record_sub_shavar_to_insert(sub_attrs)
      Severity: Major
      Found in lib/google_safe_browsing/response_helper.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          if count > 0
                            count.times do |i|
                              add_attrs[:prefix] = BinaryHelper.read_bytes_as_hex(chunk_iterator, line_actions[:hash_length])
                              record_add_shavar_to_insert(add_attrs)
                            end
        Severity: Major
        Found in lib/google_safe_browsing/response_helper.rb - About 45 mins to fix

          Method lookup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.lookup(url)
                urls = Canonicalize.urls_for_lookup(url.force_encoding('ASCII-8BIT'))
                return nil if urls.empty?
          
                hashes = HashHelper.urls_to_hashes(urls)
          Severity: Minor
          Found in lib/google_safe_browsing/api_v2.rb - 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