houston/houston-core

View on GitHub
app/concerns/project_adapter.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method has too many lines. [42/10]
Open

    def define_methods!
      concern = ProjectAdapter.const_set(concern_name, Module.new)
      concern.extend ActiveSupport::Concern

      class_methods = concern.const_set(:ClassMethods, Module.new)
Severity: Minor
Found in app/concerns/project_adapter.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.

Assignment Branch Condition size for define_methods! is too high. [36.06/15]
Open

    def define_methods!
      concern = ProjectAdapter.const_set(concern_name, Module.new)
      concern.extend ActiveSupport::Concern

      class_methods = concern.const_set(:ClassMethods, Module.new)
Severity: Minor
Found in app/concerns/project_adapter.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method define_methods! has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def define_methods!
      concern = ProjectAdapter.const_set(concern_name, Module.new)
      concern.extend ActiveSupport::Concern

      class_methods = concern.const_set(:ClassMethods, Module.new)
Severity: Minor
Found in app/concerns/project_adapter.rb - About 1 hr to fix

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

      def has_adapter(*adapter_namespaces)
        adapter_namespaces.each do |adapter_namespace|
          adapter_module = Houston::Adapters[adapter_namespace]
          raise ArgumentError, "#{adapter_module} should respond to `adapters`" unless adapter_module.respond_to?(:adapters)
          raise ArgumentError, "#{adapter_module} should respond to `adapter`" unless adapter_module.respond_to?(:adapter)
    Severity: Minor
    Found in app/concerns/project_adapter.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

    Extra blank line detected.
    Open

    
      def adapters
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Space found before comma.
    Open

          class_methods.module_eval <<-RUBY, __FILE__ , __LINE__ + 1
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    Checks for comma (,) preceded by space.

    Example:

    # bad
    [1 , 2 , 3]
    a(1 , 2)
    each { |a , b| }
    
    # good
    [1, 2, 3]
    a(1, 2)
    each { |a, b| }

    Rename has_adapter to adapter?.
    Open

      def has_adapter(*adapter_namespaces)
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cop makes sure that predicates are named properly.

    Example:

    # bad
    def is_even?(value)
    end
    
    # good
    def even?(value)
    end
    
    # bad
    def has_value?
    end
    
    # good
    def value?
    end

    Extra blank line detected.
    Open

    
    end
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Extra empty line detected at module body beginning.
    Open

    
    
    
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

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

    Example: EnforcedStyle: empty_lines

    # good
    
    module Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    module Foo
      module Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    module Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    module Foo
      def bar
        # ...
      end
    end

    Space found before comma.
    Open

          concern.module_eval <<-RUBY, __FILE__ , __LINE__ + 1
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    Checks for comma (,) preceded by space.

    Example:

    # bad
    [1 , 2 , 3]
    a(1 , 2)
    each { |a , b| }
    
    # good
    [1, 2, 3]
    a(1, 2)
    each { |a, b| }

    Extra empty line detected at class body beginning.
    Open

    
        def initialize(model, adapter_module)
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

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

    Example: EnforcedStyle: empty_lines

    # good
    
    class Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    class Foo
      class Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    class Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    class Foo
      def bar
        # ...
      end
    end

    Use empty lines between method definitions.
    Open

      def has_adapter(*adapter_namespaces)
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cop checks whether method definitions are separated by one empty line.

    NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

    AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

    Example:

    # bad
    def a
    end
    def b
    end

    Example:

    # good
    def a
    end
    
    def b
    end

    Extra empty line detected at class body end.
    Open

    
      end
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

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

    Example: EnforcedStyle: empty_lines

    # good
    
    class Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    class Foo
      class Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    class Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    class Foo
      def bar
        # ...
      end
    end

    Line is too long. [120/80]
    Open

          raise ArgumentError, "#{adapter_module} should respond to `adapters`" unless adapter_module.respond_to?(:adapters)
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    Missing top-level class documentation comment.
    Open

      class Adapter
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Line is too long. [107/80]
    Open

          raise ArgumentError, "#{adapter_namespace} has already been defined" if adapters[adapter_module.name]
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    Extra blank line detected.
    Open

    
      def has_adapter(*adapter_namespaces)
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Extra blank line detected.
    Open

    
      class Adapter
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cops checks for two or more consecutive blank lines.

    Example:

    # bad - It has two empty lines.
    some_method
    # one empty line
    # two empty lines
    some_method
    
    # good
    some_method
    # one empty line
    some_method

    Extra empty line detected at module body end.
    Open

    
    end
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

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

    Example: EnforcedStyle: empty_lines

    # good
    
    module Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    module Foo
      module Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    module Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    module Foo
      def bar
        # ...
      end
    end

    Line is too long. [118/80]
    Open

          raise ArgumentError, "#{adapter_module} should respond to `adapter`" unless adapter_module.respond_to?(:adapter)
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    Missing top-level module documentation comment.
    Open

    module ProjectAdapter
    Severity: Minor
    Found in app/concerns/project_adapter.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    There are no issues that match your filters.

    Category
    Status