superiorlu/unicorn_metrics

View on GitHub

Showing 19 of 19 total issues

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

    def raindrops_unix_listener_stats
      hash = {
        'raindrops.unix.active' => { type: :gauge, value: 0 },
        'raindrops.unix.queued' => { type: :gauge, value: 0 }
      }
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb and 1 other location - About 50 mins to fix
lib/unicorn_metrics/middleware.rb on lines 80..89

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

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 raindrops_tcp_listener_stats
      hash = {
        'raindrops.tcp.active' => { type: :gauge, value: 0 },
        'raindrops.tcp.queued' => { type: :gauge, value: 0 }
      }
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb and 1 other location - About 50 mins to fix
lib/unicorn_metrics/middleware.rb on lines 92..101

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

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

        Raindrops::Linux.tcp_listener_stats(@tcp).each do |addr, stats|
          listeners["raindrops.#{addr}.active"] = stats.active.to_s
          listeners["raindrops.#{addr}.queued"] = stats.queued.to_s
        end if @tcp
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb and 1 other location - About 20 mins to fix
lib/unicorn_metrics/middleware.rb on lines 112..115

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

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

        Raindrops::Linux.unix_listener_stats(@unix).each do |addr, stats|
          listeners["raindrops.#{addr}.active"] = stats.active.to_s
          listeners["raindrops.#{addr}.queued"] = stats.queued.to_s
        end if @unix
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb and 1 other location - About 20 mins to fix
lib/unicorn_metrics/middleware.rb on lines 108..111

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

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

required_ruby_version (1.9, declared in unicorn_metrics.gemspec) and TargetRubyVersion (2.1, declared in .rubocop.yml) should be equal.
Open

  spec.required_ruby_version = '>= 1.9.3'
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Checks that required_ruby_version of gemspec and TargetRubyVersion of .rubocop.yml are equal. Thereby, RuboCop to perform static analysis working on the version required by gemspec.

Example:

# When `TargetRubyVersion` of .rubocop.yml is `2.3`.

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.2.0'
end

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.4.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
end

Use each_value instead of each.
Open

      Raindrops::Linux.unix_listener_stats(@unix).each do |_, stats|
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb by rubocop

This cop checks for uses of each_key and each_value Hash methods.

Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Unnecessary utf-8 encoding comment.
Open

# -*- encoding: utf-8 -*-
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency pry should appear before rubocop.
Open

  spec.add_development_dependency('pry', '~> 0.10.3')
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency cloudinsight-sdk should appear before raindrops.
Open

  spec.add_dependency('cloudinsight-sdk', '~> 0.0.1')
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

Extra empty line detected at block body end.
Open


end
Severity: Minor
Found in Guardfile by rubocop

This cops checks if empty lines around the bodies of blocks match the configuration.

Example: EnforcedStyle: empty_lines

# good

foo do |bar|

  # ...

end

Example: EnforcedStyle: noemptylines (default)

# good

foo do |bar|
  # ...
end

Method UnicornMetrics.app_name is defined at both lib/unicorn_metrics.rb:5 and lib/unicorn_metrics.rb:21.
Open

    def app_name
Severity: Minor
Found in lib/unicorn_metrics.rb by rubocop

This cop checks for duplicated instance (or singleton) method definitions.

Example:

# bad

def duplicated
  1
end

def duplicated
  2
end

Example:

# bad

def duplicated
  1
end

alias duplicated other_duplicated

Example:

# good

def duplicated
  1
end

def other_duplicated
  2
end

Use each_value instead of each.
Open

      Raindrops::Linux.tcp_listener_stats(@tcp).each do |_, stats|
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb by rubocop

This cop checks for uses of each_key and each_value Hash methods.

Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Add an empty line after magic comments.
Open

lib = File.expand_path('../lib', __FILE__)
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Favor a normal if-statement over a modifier clause in a multiline statement.
Open

        Raindrops::Linux.unix_listener_stats(@unix).each do |addr, stats|
          listeners["raindrops.#{addr}.active"] = stats.active.to_s
          listeners["raindrops.#{addr}.queued"] = stats.queued.to_s
        end if @unix
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb by rubocop

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency minitest should appear before rake.
Open

  spec.add_development_dependency('minitest', '~> 5.8')
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency guard should appear before minitest-reporters.
Open

  spec.add_development_dependency('guard', '~> 2.13')
Severity: Minor
Found in unicorn_metrics.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

Favor a normal if-statement over a modifier clause in a multiline statement.
Open

        Raindrops::Linux.tcp_listener_stats(@tcp).each do |addr, stats|
          listeners["raindrops.#{addr}.active"] = stats.active.to_s
          listeners["raindrops.#{addr}.queued"] = stats.queued.to_s
        end if @tcp
Severity: Minor
Found in lib/unicorn_metrics/middleware.rb by rubocop

Checks for uses of if/unless modifiers with multiple-lines bodies.

Example:

# bad
{
  result: 'this should not happen'
} unless cond

# good
{ result: 'ok' } if cond

TODO found
Open

TODO
Severity: Minor
Found in README.md by fixme

TODO found
Open

## TODO:
Severity: Minor
Found in README.md by fixme
Severity
Category
Status
Source
Language