avit/stockboy

View on GitHub

Showing 15 of 15 total issues

Class Job has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Job

    # Defines the data source for receiving data
    #
    # @return [Provider]
Severity: Minor
Found in lib/stockboy/job.rb - About 2 hrs to fix

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

        def initialize(opts={}, &block)
          super(opts, &block)
          @host         = opts[:host]
          @username     = opts[:username]
          @password     = opts[:password]
    Severity: Major
    Found in lib/stockboy/providers/imap.rb and 1 other location - About 1 hr to fix
    lib/stockboy/providers/ftp.rb on lines 98..113

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

    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

        def initialize(opts={}, &block)
          super(opts, &block)
          @host         = opts[:host]
          @passive      = opts[:passive]
          @username     = opts[:username]
    Severity: Major
    Found in lib/stockboy/providers/ftp.rb and 1 other location - About 1 hr to fix
    lib/stockboy/providers/imap.rb on lines 131..146

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

    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 dsl_attr has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def dsl_attr(attr, options={})
          if options.fetch(:attr_accessor, true)
            attr_reader attr if options.fetch(:attr_reader, true)
            attr_writer attr if options.fetch(:attr_writer, true)
          end
    Severity: Minor
    Found in lib/stockboy/dsl.rb - About 1 hr to fix

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

          def client_options
            opts = if wsdl
              {wsdl: wsdl}
            elsif endpoint
              {endpoint: endpoint}
      Severity: Minor
      Found in lib/stockboy/providers/soap.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 each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def each
            return to_enum unless block_given?
            enum = to_enum
            while true
              begin
      Severity: Minor
      Found in lib/stockboy/provider_repeater.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 client has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def client
            raise(ArgumentError, "no block given") unless block_given?
            first_connection = @open_client.nil?
            if first_connection
              @open_client = ::Net::IMAP.new(host)
      Severity: Minor
      Found in lib/stockboy/providers/imap.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 translator_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.translator_for(attr, lookup)
            if lookup.respond_to?(:call)
              lookup
            elsif tr = self[lookup]
              tr.is_a?(Class) && tr < Stockboy::Translator ? tr.new(attr) : tr
      Severity: Minor
      Found in lib/stockboy/translations.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 translate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def translate(col)
            @tr_table.fetch(col.to) do |key|
              return @tr_table[key] = sanitize(@table[col.from]) if col.translators.empty?
              fields = raw_hash
              tr_input = col.translators.reduce(input) do |value, tr|
      Severity: Minor
      Found in lib/stockboy/candidate_record.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 adapter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def adapter
            return yield @open_adapter if @open_adapter
      
            adapter_class.new(self).open do |ftp|
              @open_adapter = ftp
      Severity: Minor
      Found in lib/stockboy/providers/ftp.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(data)
            validate_headers
            data.force_encoding(encoding) if encoding
            data = StringIO.new(data) unless data.is_a? StringIO
            skip_header_rows.times { data.readline }
      Severity: Minor
      Found in lib/stockboy/readers/fixed_width.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 with_provider_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def with_provider_data
            return to_enum(__method__) unless block_given?
            yielded = nil
            provider.data do |data|
              if data
      Severity: Minor
      Found in lib/stockboy/job.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 dsl_attr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def dsl_attr(attr, options={})
            if options.fetch(:attr_accessor, true)
              attr_reader attr if options.fetch(:attr_reader, true)
              attr_writer attr if options.fetch(:attr_writer, true)
            end
      Severity: Minor
      Found in lib/stockboy/dsl.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(data)
            hash = if data.is_a? Hash
              data
            else
              if data.respond_to? :to_xml
      Severity: Minor
      Found in lib/stockboy/readers/xml.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate
            errors << "uri must be specified" unless uri
            errors << "method (:get, :post) must be specified" unless method
            errors << "body must be specified" if [:post, :put, :patch].include?(method) && body.to_s.empty?
            errors.empty?
      Severity: Minor
      Found in lib/stockboy/providers/http.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