andriy-baran/hospodar

View on GitHub

Showing 40 of 40 total issues

Method has too many lines. [16/15]
Open

    def define_component_adding_method
      mod = self
      define_method(component_name) do |title, base_class: nil, init: nil|
        singleton_class.class_eval do
          reader_name = mod.component_class_reader(title)
Severity: Minor
Found in lib/hospodar/dsl.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

      def nest(title, base_class: Class.new(Object), init: nil, delegate: false, on_exception: nil, &block)
        nested_struct(title, base_class: base_class.include(Exceptional), init: init)
        class_eval(&block)
        Nested.new(self, on_exception, delegate).for(title, &block).inject_method
Severity: Minor
Found in lib/hospodar/builder.rb and 1 other location - About 35 mins to fix
lib/hospodar/builder.rb on lines 74..77

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

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 wrap(title, base_class: Class.new(Object), init: nil, delegate: false, on_exception: nil, &block)
        wrapped_struct(title, base_class: base_class.include(Exceptional), init: init)
        class_eval(&block)
        Wrapped.new(self, on_exception, delegate).for(title, &block).inject_method
Severity: Minor
Found in lib/hospodar/builder.rb and 1 other location - About 35 mins to fix
lib/hospodar/builder.rb on lines 80..83

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

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

Line is too long. [81/80]
Open

        mount = Strategies::Mount.new(inject, plan, target, builder_params.title)
Severity: Minor
Found in lib/hospodar/builder/flatten.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [81/80]
Open

        Nested.new(self, on_exception, delegate).for(title, &block).inject_method
Severity: Minor
Found in lib/hospodar/builder.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [82/80]
Open

        return method(mod.new_instance_method_name(step)) if init_method.arity < 2
Severity: Minor
Found in lib/hospodar/builder/helpers.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [107/80]
Open

      def nest(title, base_class: Class.new(Object), init: nil, delegate: false, on_exception: nil, &block)
Severity: Minor
Found in lib/hospodar/builder.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [86/80]
Open

        flatten_struct(title, base_class: base_class.include(Exceptional), init: init)
Severity: Minor
Found in lib/hospodar/builder.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [101/80]
Open

              Hospodar::Builder.def_accessor(title, on: layer_object, to: object, delegate: delegate)

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [82/80]
Open

        factory.define_singleton_method(@planing_method) do |object, title, group|
Severity: Minor
Found in lib/hospodar/builder/assembler.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [110/80]
Open

      raise(ArgumentError, "must be a subclass of #{base_class.inspect}") unless component_class <= base_class
Severity: Minor
Found in lib/hospodar/subclassing_helpers.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [98/80]
Open

      define_method mod.configure_component_method_name(title) do |klass = nil, init: nil, &block|
Severity: Minor
Found in lib/hospodar/dsl.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

unexpected token error (Using Ruby 2.2 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

          @block&.call(@builder)

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

Line is too long. [88/80]
Open

        init_method = public_send(mod.component_class_reader(step)).method(:__ms_init__)
Severity: Minor
Found in lib/hospodar/builder/helpers.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [85/80]
Open

        nested_struct(title, base_class: base_class.include(Exceptional), init: init)
Severity: Minor
Found in lib/hospodar/builder.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Freeze mutable objects assigned to constants.
Open

  VERSION = '1.0.1'
Severity: Minor
Found in lib/hospodar/version.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.

Example: EnforcedStyle: literals (default)

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

# good
CONST = <<~TESTING.freeze
  This is a heredoc
TESTING

# good
CONST = Something.new

Example: EnforcedStyle: strict

# bad
CONST = Something.new

# bad
CONST = Struct.new do
  def foo
    puts 1
  end
end

# good
CONST = Something.new.freeze

# good
CONST = Struct.new do
  def foo
    puts 1
  end
end.freeze

When using method_missing, fall back on super.
Open

    def method_missing(name, **kws)
      @definitions[name] = kws.keep_if do |key, _|
        %i[base_class init].include?(key)
      end
    end
Severity: Minor
Found in lib/hospodar/group_definition.rb by rubocop

This cop checks for the presence of method_missing without falling back on super.

Example:

#bad
def method_missing(name, *args)
  # ...
end

#good

def method_missing(name, *args)
  # ...
  super
end

Line is too long. [82/80]
Open

        return public_send(:"build_#{step}") if %i[flat wrap nest].include?(group)
Severity: Minor
Found in lib/hospodar/builder/helpers.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [105/80]
Open

        mod = included_modules.detect { |m| m.respond_to?(:component_name) && m.component_name == group }
Severity: Minor
Found in lib/hospodar/builder/helpers.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Line is too long. [81/80]
Open

        ids = plan[0..1].transpose.map { |g, e| Hospodar::Builder::Id.new(g, e) }
Severity: Minor
Found in lib/hospodar/builder/flatten.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Severity
Category
Status
Source
Language