shadowbq/threatinator

View on GitHub

Showing 24 of 24 total issues

Method run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(opts = {})
      ios = [ ]
      logger.debug("#run starting #{@feed.provider}:#{@feed.name}") if logger.debug?
      start = Time.now
      changed(true); notify_observers(:start)
Severity: Minor
Found in lib/threatinator/feed_runner.rb - About 1 hr to fix

    Method run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(opts = {})
          ios = [ ]
          logger.debug("#run starting #{@feed.provider}:#{@feed.name}") if logger.debug?
          start = Time.now
          changed(true); notify_observers(:start)
    Severity: Minor
    Found in lib/threatinator/feed_runner.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 output_table has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def output_table(io_out)
    
              feed_info = [['provider', 'name', 'type', 'link/path', 'event_types']]
    
              registry.each do |feed|
    Severity: Minor
    Found in lib/threatinator/actions/list/action.rb - About 1 hr to fix

      Method _init_mod has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def _init_mod
              parser = self
              Module.new do
                extend Helpers
                extend GLI::App
      Severity: Minor
      Found in lib/threatinator/cli/parser.rb - About 1 hr to fix

        Method build has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def build
              opts = {
                feed_provider: @feed_provider,
                feed_name: @feed_name,
              }
        Severity: Minor
        Found in lib/threatinator/event_builder.rb - About 1 hr to fix

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

              def build
                opts = {
                  feed_provider: @feed_provider,
                  feed_name: @feed_name,
                }
          Severity: Minor
          Found in lib/threatinator/event_builder.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 parse_record has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def parse_record(record)
                @built_events.clear
                events = []
                changed(true); notify_observers(:start_parse_record, record)
          
          
          Severity: Minor
          Found in lib/threatinator/feed_runner.rb - About 1 hr to fix

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

                  def self.properties(namespace = nil)
                    ret = {}
                    self.attribute_set.each do |attribute|
                      name = attribute.name.to_s
                      unless namespace.nil?
            Severity: Minor
            Found in lib/threatinator/config/base.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 load_files has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def load_files(file_names)
                  file_names.each do |file_name|
                    path, type, name = split_file_name(file_name)
                    next if path.nil?
                    # Don't try to load unit tests as plugins :)
            Severity: Minor
            Found in lib/threatinator/plugin_loader.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def initialize(name, opts = {})
                      unless name.kind_of?(::Symbol) or name.kind_of?(::String)
                        raise TypeError.new("name must be a String or a Symbol")
                      end
            
            
            Severity: Minor
            Found in lib/threatinator/parsers/xml/node.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 _init_mod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def _init_mod
                    parser = self
                    Module.new do
                      extend Helpers
                      extend GLI::App
            Severity: Minor
            Found in lib/threatinator/cli/parser.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 start_element_namespace has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
            Severity: Minor
            Found in lib/threatinator/parsers/xml/sax_document.rb - About 35 mins to fix

              Method from_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.from_string(str, filename = nil, lineno = nil)
                    from_dsl do
                      args = [str, binding]
                      unless filename.nil?
                        args << filename
              Severity: Minor
              Found in lib/threatinator/feed_builder.rb - 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

              Method each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def each(type = nil)
                    return enum_for(:each, type) unless block_given?
                    @plugin_types_registry.each do |t, type_registry|
                      unless type.nil?
                        next unless type.to_sym == t
              Severity: Minor
              Found in lib/threatinator/plugin_loader.rb - 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

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

                class Parser
                  # @param [Hash] opts An options hash. See subclasses for details.
                  def initialize(opts = {})
                  end
              
              
              Severity: Minor
              Found in lib/threatinator/parser.rb and 1 other location - About 25 mins to fix
              lib/threatinator/fetcher.rb on lines 2..20

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

              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

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

                      def _build_csv_opts
                        opts = {}.merge(@csv_opts)
                        opts[:return_headers] = true
                        opts[:row_sep] = @row_separator unless @row_separator.nil?
                        opts[:col_sep] = @col_separator unless @col_separator.nil?
              Severity: Minor
              Found in lib/threatinator/parsers/csv/parser.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

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

                    def decode(io)
                      zio = Zlib::GzipReader.new(io, encoding: "binary")
                      tempfile = Tempfile.new("threatinator", encoding: "binary")
                      while chunk = zio.read(10240)
                        tempfile.write(chunk)
              Severity: Minor
              Found in lib/threatinator/decoders/gzip.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

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

                    def config
                      run_hash = config_hash["run"] || {}
                      run_hash['observers'] ||= []
              
                      if filename = run_hash['coverage_output']
              Severity: Minor
              Found in lib/threatinator/cli/run_action_builder.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

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

                      def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
                        @element_stack.push(name)
              
                        if @parsing_stack.empty?
                          if @element_stack.length > @max_depth
              Severity: Minor
              Found in lib/threatinator/parsers/xml/sax_document.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

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

                      def run(io)
                        lineno = 1
                        previous_pos = io.pos
                        csv = ::CSV.new(io, _build_csv_opts())
                        csv.each do |row|
              Severity: Minor
              Found in lib/threatinator/parsers/csv/parser.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