sonots/haikanko

View on GitHub

Showing 47 of 47 total issues

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

  class VisualizerController < ResourceController
    set :views, File.join(File.dirname(__FILE__), '..', 'views', 'visualizer')
    set :layout, './layout'
    include ::Web::DeployHelper

Severity: Major
Found in web/controllers/visualizer_controller.rb and 1 other location - About 1 day to fix
web/controllers/notifier_controller.rb on lines 4..119

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

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

  class NotifierController < ResourceController
    set :views, File.join(File.dirname(__FILE__), '..', 'views', 'notifier')
    set :layout, './layout'
    include ::Web::DeployHelper

Severity: Major
Found in web/controllers/notifier_controller.rb and 1 other location - About 1 day to fix
web/controllers/visualizer_controller.rb on lines 4..119

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

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

  def generate_output(count)
    output = {}
    if @aggregate == :all
      c = count['all']
      if c[:num] then output['num'] = c[:num] end
Severity: Minor
Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - 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 bootstrap-datepicker.js has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* =========================================================
 * bootstrap-datepicker.js 
 * http://www.eyecon.ro/bootstrap-datepicker
 * =========================================================
 * Copyright 2012 Stefan Petre
Severity: Minor
Found in web/public/js/bootstrap-datepicker.js - About 4 hrs to fix

    Function fill has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            fill: function() {
                var d = new Date(this.viewDate),
                    year = d.getFullYear(),
                    month = d.getMonth(),
                    currentDate = this.date.valueOf();
    Severity: Major
    Found in web/public/js/bootstrap-datepicker.js - About 2 hrs to fix

      Method emit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def emit(tag, es, chain)
          ntag, targets = @match_cache[tag]
          unless targets
            ntag = tag.sub(@prefix_match, @tag_prefix)
            targets = []
      Severity: Minor
      Found in pipework/fluentd/server/plugin/out_route.rb - About 2 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 click has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              click: function(e) {
                  e.stopPropagation();
                  e.preventDefault();
                  var target = $(e.target).closest('span, td, th');
                  if (target.length == 1) {
      Severity: Major
      Found in web/public/js/bootstrap-datepicker.js - About 2 hrs to fix

        Method emit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def emit(tag, es, chain)
            messages = []
            privmsg_messages = []
        
            es.each {|time,record|
        Severity: Minor
        Found in pipework/fluentd/server/plugin/out_ikachan.rb - About 2 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

        Method agent_opt_parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def agent_opt_parse
          hostnames = []
          if ENV['LABEL']
            hostnames = Feature.hostnames(ENV['LABEL'].split(","))
            $stderr.puts 'LABEL does not exist' and exit unless hostnames.present?
        Severity: Minor
        Found in pipework/mina/agent.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 receive_lines has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def receive_lines(lines)
            lines.each do |line|
              next if line == ""
              case @line_number
              when 0..1
        Severity: Minor
        Found in pipework/fluentd/server/plugin/in_dstat.rb - About 1 hr to fix

          Method included has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.included(controller)
              controller.helpers do
          
                def h(text)
                  Rack::Utils.escape_html(text)
          Severity: Minor
          Found in web/lib/sinatra_helper.rb - About 1 hr to fix

            Method emit has a Cognitive Complexity of 14 (exceeds 5 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

            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

                messages.each do |msg|
                  begin
                    lines = msg.split("\n")
                    limited_lines = lines[0, @max_lines]
                    limited_lines += [lines.last] if lines.size > @max_lines
            Severity: Major
            Found in pipework/fluentd/server/plugin/out_ikachan.rb and 1 other location - About 1 hr to fix
            pipework/fluentd/server/plugin/out_ikachan.rb on lines 99..109

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

            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

                privmsg_messages.each do |msg|
                  begin
                    lines = msg.split("\n")
                    limited_lines = lines[0, @max_lines]
                    limited_lines += [lines.last] if lines.size > @max_lines
            Severity: Major
            Found in pipework/fluentd/server/plugin/out_ikachan.rb and 1 other location - About 1 hr to fix
            pipework/fluentd/server/plugin/out_ikachan.rb on lines 85..95

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

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

              def receive_lines(lines)
                lines.each do |line|
                  next if line == ""
                  case @line_number
                  when 0..1
            Severity: Minor
            Found in pipework/fluentd/server/plugin/in_dstat.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 countups has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def countups(tag, min, max, sum, num, sample)
                if @aggregate == :all
                  tag = 'all'
                end
            
            
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_numeric_monitor.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 generate_output has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def generate_output(count)
                output = {}
                if @aggregate == :all
                  c = count['all']
                  if c[:num] then output['num'] = c[:num] end
            Severity: Minor
            Found in pipework/fluentd/server/plugin/out_numeric_monitor.rb - About 1 hr to fix

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

                def emit(tag, es, chain)
                  messages = []
                  privmsg_messages = []
              
                  es.each {|time,record|
              Severity: Minor
              Found in pipework/fluentd/server/plugin/out_ikachan.rb - About 1 hr to fix

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

                  def emit(tag, es, chain)
                    ntag, targets = @match_cache[tag]
                    unless targets
                      ntag = tag.sub(@prefix_match, @tag_prefix)
                      targets = []
                Severity: Minor
                Found in pipework/fluentd/server/plugin/out_route.rb - About 1 hr to fix

                  Method worker_deployed? has a Cognitive Complexity of 11 (exceeds 5 allowed). 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: 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

                  Severity
                  Category
                  Status
                  Source
                  Language