lib/extended_content_test_unit_helper.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Module has too many lines. [101/100]
Open

module ExtendedContentTestUnitHelper
  # xml attributes pulls extended_content column xml out into a hash
  # TODO: test case where the model is a topic and we need form fields from ancestors
  # TODO: test case where extended_field is a multiple
  # TODO: test that position is in right order?

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

Assignment Branch Condition size for included is too high. [55.05/15]
Open

  def self.included(base)
    base.class_eval do
      # test around setter and getter methods generated for each extended field
      context 'An extended field mapped to a type' do
        setup do

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 has too many lines. [39/10]
Open

  def self.included(base)
    base.class_eval do
      # test around setter and getter methods generated for each extended field
      context 'An extended field mapped to a type' do
        setup do

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 test_extended_content_pairs is too high. [22.09/15]
Open

  def test_extended_content_pairs
    # Test with a single node
    model = Module.class_eval(@base_class).create!(new_model_attributes)
    model.update_attribute(:extended_content, '<some_tag xml_element_name="dc:something">something</some_tag>')

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

Assignment Branch Condition size for test_extended_content_with_multiple_nodes is too high. [17.03/15]
Open

  def test_extended_content_with_multiple_nodes
    model = Module.class_eval(@base_class).create!(new_model_attributes)
    model.update_attribute(:extended_content, '<some_tag xml_element_name="dc:something">something</some_tag><some_other_tag xml_element_name="dc:something_else">something_else</some_other_tag>')

    assert model.valid?

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 included has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.included(base)
    base.class_eval do
      # test around setter and getter methods generated for each extended field
      context 'An extended field mapped to a type' do
        setup do
Severity: Minor
Found in lib/extended_content_test_unit_helper.rb - About 1 hr to fix

    Block has too many lines. [37/25]
    Open

        base.class_eval do
          # test around setter and getter methods generated for each extended field
          context 'An extended field mapped to a type' do
            setup do
              create_and_map_extended_field_to_type(label: 'Some tag')

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Block has too many lines. [33/25]
    Open

          context 'An extended field mapped to a type' do
            setup do
              create_and_map_extended_field_to_type(label: 'Some tag')
            end
    
    

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Method included has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.included(base)
        base.class_eval do
          # test around setter and getter methods generated for each extended field
          context 'An extended field mapped to a type' do
            setup do
    Severity: Minor
    Found in lib/extended_content_test_unit_helper.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

    TODO found
    Open

      # TODO: test that position is in right order?

    TODO found
    Open

      # TODO: test case where the model is a topic and we need form fields from ancestors

    TODO found
    Open

      # TODO: test case where extended_field is a multiple

    Useless private access modifier.
    Open

          private

    This cop checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

    Example:

    class Foo
      public # this is redundant (default access is public)
    
      def method
      end
    
      private # this is not redundant (a method is defined)
      def method2
      end
    
      private # this is redundant (no following methods are defined)
    end

    Example:

    class Foo
      # The following is not redundant (conditionally defined methods are
      # considered as always defining a method)
      private
    
      if condition?
        def method
        end
      end
    
      protected # this is not redundant (method is defined)
    
      define_method(:method2) do
      end
    
      protected # this is redundant (repeated from previous modifier)
    
      [1,2,3].each do |i|
        define_method("foo#{i}") do
        end
      end
    
      # The following is redundant (methods defined on the class'
      # singleton class are not affected by the public modifier)
      public
    
      def self.method3
      end
    end

    Example:

    # Lint/UselessAccessModifier:
    #   ContextCreatingMethods:
    #     - concerning
    require 'active_support/concern'
    class Foo
      concerning :Bar do
        def some_public_method
        end
    
        private
    
        def some_private_method
        end
      end
    
      # this is not redundant because `concerning` created its own context
      private
    
      def some_other_private_method
      end
    end

    Example:

    # Lint/UselessAccessModifier:
    #   MethodCreatingMethods:
    #     - delegate
    require 'active_support/core_ext/module/delegation'
    class Foo
      # this is not redundant because `delegate` creates methods
      private
    
      delegate :method_a, to: :method_b
    end

    There are no issues that match your filters.

    Category
    Status