sonots/haikanko

View on GitHub

Showing 47 of 47 total issues

Method agent_deployed? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def agent_deployed?(hostname)
    hist = History.find_by(host: hostname, node_type: "agent")
    if enabled?
      return false if hist.nil? or hist.deployed_at.nil?
      hist.deployed_at >= self.agent_updated_at if self.agent_updated_at
Severity: Minor
Found in models/feature.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 configure has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def configure(conf)
    super

    if @remove_prefix
      @removed_prefix_string = @remove_prefix + '.'
Severity: Minor
Found in pipework/fluentd/server/plugin/out_hash_forward.rb - About 1 hr to fix

    Method configure has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def configure(conf)
        super
    
        @channel = '#' + @channel
        @join_uri = URI.parse "http://#{@host}:#{@port}/join"
    Severity: Minor
    Found in pipework/fluentd/server/plugin/out_ikachan.rb - About 1 hr to fix

      Function Datepicker has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var Datepicker = function(element, options){
              this.element = $(element);
              this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
              this.picker = $(DPGlobal.template)
                                  .appendTo('body')
      Severity: Minor
      Found in web/public/js/bootstrap-datepicker.js - About 1 hr to fix

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

          def configure(conf)
            super
        
            @out_keys = @out_keys.split(',')
            @message_out_keys = @message_out_keys.split(',')
        Severity: Minor
        Found in pipework/fluentd/server/plugin/out_mail.rb - About 1 hr to fix

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

            def emit(tag, es, chain)
              min = nil
              max = nil
              sum = 0
              num = 0
          Severity: Minor
          Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 1 hr to fix

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

              def configure(conf)
                super
            
                @channel = '#' + @channel
                @join_uri = URI.parse "http://#{@host}:#{@port}/join"
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_ikachan.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 call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def call(env)
                  began_at = Time.now
                  begin
                    status, header, body = @app.call(env)
                  rescue => e
            Severity: Minor
            Found in web/lib/request_logger.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

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

              def worker_deployed?(hostname)
                hist = History.find_by(host: hostname, node_type: "worker")
                if enabled?
                  return false if hist.nil? or hist.deployed_at.nil?
                  hist.deployed_at >= self.updated_at if self.updated_at
            Severity: Major
            Found in models/feature.rb and 1 other location - About 1 hr to fix
            models/feature.rb on lines 114..121

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

            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 agent_deployed?(hostname)
                hist = History.find_by(host: hostname, node_type: "agent")
                if enabled?
                  return false if hist.nil? or hist.deployed_at.nil?
                  hist.deployed_at >= self.agent_updated_at if self.agent_updated_at
            Severity: Major
            Found in models/feature.rb and 1 other location - About 1 hr to fix
            models/feature.rb on lines 125..132

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

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

              def configure(conf)
                super
            
                @out_keys = @out_keys.split(',')
                @message_out_keys = @message_out_keys.split(',')
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_mail.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 emit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def emit(tag, es, chain)
                if @remove_prefix and
                    ( (tag.start_with?(@removed_prefix_string) and tag.length > @removed_length) or tag == @remove_prefix)
                  tag = tag[@removed_length..-1]
                end 
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_hash_forward.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 count_initialized has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def count_initialized(keys=nil)
                # counts['tag'] = {:min => num, :max => num, :sum => num, :num => num [, :sample => [....]]}
                if @aggregate == :all
                  if @percentiles
                    {'all' => {:min => nil, :max => nil, :sum => nil, :num => 0, :sample => []}}
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_numeric_monitor.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 countups has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def countups(tag, min, max, sum, num, sample)
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 45 mins to fix

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

                def configure(conf)
                  super
              
                  if @unit
                    @count_interval = case @unit
              Severity: Minor
              Found in pipework/fluentd/server/plugin/out_numeric_monitor.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 configure has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def configure(conf)
                  super
              
                  if @remove_prefix
                    @removed_prefix_string = @remove_prefix + '.'
              Severity: Minor
              Found in pipework/fluentd/server/plugin/out_hash_forward.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 evaluate_message has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def evaluate_message(message, out_keys, tag, time, record)
              Severity: Minor
              Found in pipework/fluentd/server/plugin/out_ikachan.rb - About 35 mins to fix

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

                    post '/:irc_id/duplicate' do |irc_id|
                      redirect '/' unless irc = Irc.find(irc_id)
                      @irc = irc.duplicate(params['irc'])
                
                      if @irc.error?
                Severity: Minor
                Found in web/controllers/irc_controller.rb and 1 other location - About 35 mins to fix
                web/controllers/email_controller.rb on lines 61..70

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

                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

                    post '/:email_id/duplicate' do |email_id|
                      redirect '/' unless email = Email.find(email_id)
                      @email = email.duplicate(params['email'])
                
                      if @email.error?
                Severity: Minor
                Found in web/controllers/email_controller.rb and 1 other location - About 35 mins to fix
                web/controllers/irc_controller.rb on lines 61..70

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

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

                def remote_file(target_path, source_path = nil)
                  contents = nil
                  if block_given?
                    contents = yield
                    source_path = create_tempfile(contents)
                Severity: Minor
                Found in pipework/lib/mina_helper.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

                Severity
                Category
                Status
                Source
                Language