wearefine/fae

View on GitHub
lib/generators/fae/base_generator.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class has too many lines. [181/100]
Open

  class BaseGenerator < Rails::Generators::NamedBase
    source_root ::File.expand_path('../templates', __FILE__)
    argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
    class_option :namespace, type: :string, default: 'admin', desc: 'Sets the namespace of the generator'
    class_option :template, type: :string, default: 'slim', desc: 'Sets the template engine of the generator'

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

Assignment Branch Condition size for generate_view_files is too high. [35.69/15]
Open

    def generate_view_files
      @toggle_attrs = set_toggle_attrs
      @form_attrs = set_form_attrs
      @association_names = @@association_names
      @attachments = @@attachments

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

    def set_globals
      if attributes.present?
        attributes.each do |arg|
          # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
          if is_attachment(arg)

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. [24/10]
Open

    def set_globals
      if attributes.present?
        attributes.each do |arg|
          # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
          if is_attachment(arg)

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.

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

    def inject_model_attachments
      return if @@attachments.blank?
      @@attachments.each do |attachment|
        if attachment.type == :image
          inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" 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.

Method set_globals has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def set_globals
      if attributes.present?
        attributes.each do |arg|
          # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
          if is_attachment(arg)
Severity: Minor
Found in lib/generators/fae/base_generator.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

Class BaseGenerator has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class BaseGenerator < Rails::Generators::NamedBase
    source_root ::File.expand_path('../templates', __FILE__)
    argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
    class_option :namespace, type: :string, default: 'admin', desc: 'Sets the namespace of the generator'
    class_option :template, type: :string, default: 'slim', desc: 'Sets the template engine of the generator'
Severity: Minor
Found in lib/generators/fae/base_generator.rb - About 2 hrs to fix

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

        def graphql_type(type)
          case type.to_s
          when 'integer'
            'Integer'
          when 'boolean'

    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.

    Perceived complexity for set_globals is too high. [10/7]
    Open

        def set_globals
          if attributes.present?
            attributes.each do |arg|
              # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
              if is_attachment(arg)

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Cyclomatic complexity for set_globals is too high. [8/6]
    Open

        def set_globals
          if attributes.present?
            attributes.each do |arg|
              # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
              if is_attachment(arg)

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Assignment Branch Condition size for inject_model_attachments is too high. [17.46/15]
    Open

        def inject_model_attachments
          return if @@attachments.blank?
          @@attachments.each do |attachment|
            if attachment.type == :image
              inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" 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. [11/10]
    Open

        def generate_view_files
          @toggle_attrs = set_toggle_attrs
          @form_attrs = set_form_attrs
          @association_names = @@association_names
          @attachments = @@attachments

    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.

    Use 2 (not 4) spaces for indentation.
    Open

                inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

    Block body expression is on the same line as the block start.
    Open

          inject_into_file "config/routes.rb", after: "namespace :#{options.namespace} do\n", force: true do <<-RUBY

    This cop checks whether the multiline do end blocks have a newline after the start of the block. Additionally, it checks whether the block arguments, if any, are on the same line as the start of the block.

    Example:

    # bad
    blah do |i| foo(i)
      bar(i)
    end
    
    # bad
    blah do
      |i| foo(i)
      bar(i)
    end
    
    # good
    blah do |i|
      foo(i)
      bar(i)
    end
    
    # bad
    blah { |i| foo(i)
      bar(i)
    }
    
    # good
    blah { |i|
      foo(i)
      bar(i)
    }

    Line is too long. [112/80]
    Open

          inject_into_file "config/routes.rb", after: "namespace :#{options.namespace} do\n", force: true do <<-RUBY

    Use 2 spaces for indentation in a heredoc by using some library(e.g. ActiveSupport's String#strip_heredoc).
    Open

    \n  acts_as_list add_new_at: :top
      default_scope { order(:position) }\n
    RUBY

    This cops checks the indentation of the here document bodies. The bodies are indented one step. In Ruby 2.3 or newer, squiggly heredocs (<<~) should be used. If you use the older rubies, you should introduce some library to your project (e.g. ActiveSupport, Powerpack or Unindent). Note: When Metrics/LineLength's AllowHeredoc is false(not default), this cop does not add any offenses for long here documents to avoid Metrics/LineLength's offenses.

    Example:

    # bad
    <<-RUBY
    something
    RUBY
    
    # good
    # When EnforcedStyle is squiggly, bad code is auto-corrected to the
    # following code.
    <<~RUBY
      something
    RUBY
    
    # good
    # When EnforcedStyle is active_support, bad code is auto-corrected to
    # the following code.
    <<-RUBY.strip_heredoc
      something
    RUBY

    Line is too long. [138/80]
    Open

          template "views/index.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/index.html.#{options.template}"

    Line is too long. [106/80]
    Open

            inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do <<-RUBY

    Line is too long. [100/80]
    Open

              inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do

    Use %w or %W for an array of words.
    Open

          rejected_attrs = ['position', 'on_stage', 'on_prod']

    This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.

    Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of 3 will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %w[foo bar baz]
    
    # bad
    ['foo', 'bar', 'baz']

    Example: EnforcedStyle: brackets

    # good
    ['foo', 'bar', 'baz']
    
    # bad
    %w[foo bar baz]

    Line is too long. [137/80]
    Open

          copy_file "views/edit.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/edit.html.#{options.template}"

    Avoid the use of the case equality operator ===.
    Open

              @@has_position = true if arg.name === 'position'

    This cop checks for uses of the case equality operator(===).

    Example:

    # bad
    Array === something
    (1..100) === 7
    /something/ === some_string
    
    # good
    something.is_a?(Array)
    (1..100).include?(7)
    some_string =~ /something/

    Replace class var @@graphql_attributes with a class instance var.
    Open

        @@graphql_attributes = []

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

          if @@has_position

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Indent access modifiers like private.
    Open

      private

    Modifiers should be indented as deep as method definitions, or as deep as the class/module keyword, depending on configuration.

    Example: EnforcedStyle: indent (default)

    # bad
    class Plumbus
    private
      def smooth; end
    end
    
    # good
    class Plumbus
      private
      def smooth; end
    end

    Example: EnforcedStyle: outdent

    # bad
    class Plumbus
      private
      def smooth; end
    end
    
    # good
    class Plumbus
    private
      def smooth; end
    end

    Line is too long. [125/80]
    Open

              # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options

    Line is too long. [113/80]
    Open

          inject_into_file "app/models/#{file_name}.rb", after: /(ActiveRecord::Base|ApplicationRecord)\n/ do <<-RUBY

    Rename is_attachment to attachment?.
    Open

        def is_attachment(arg)

    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

    Line is too long. [133/80]
    Open

          line = "item('#{plural_file_name.humanize.titlecase}', path: #{options.namespace}_#{plural_file_name}_path),\n\s\s\s\s\s\s\s\s"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

                @@attributes_flat << "#{arg.name}:#{arg.type}" + (arg.has_index? ? ":index" : "")

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Use %w or %W for an array of words.
    Open

        Rails::Generators::GeneratedAttribute::DEFAULT_TYPES += ['image', 'file', 'seo_set']

    This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.

    Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of 3 will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %w[foo bar baz]
    
    # bad
    ['foo', 'bar', 'baz']

    Example: EnforcedStyle: brackets

    # good
    ['foo', 'bar', 'baz']
    
    # bad
    %w[foo bar baz]

    Use %w or %W for an array of words.
    Open

          ['active', 'on_stage', 'on_prod'] & @@attribute_names

    This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.

    Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of 3 will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %w[foo bar baz]
    
    # bad
    ['foo', 'bar', 'baz']

    Example: EnforcedStyle: brackets

    # good
    ['foo', 'bar', 'baz']
    
    # bad
    %w[foo bar baz]

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

          if attributes.present?

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    Final newline missing.
    Open

    end

    Line is too long. [105/80]
    Open

        class_option :namespace, type: :string, default: 'admin', desc: 'Sets the namespace of the generator'

    Replace class var @@attributes_flat with a class instance var.
    Open

        @@attributes_flat = []

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

        argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          template "graphql/graphql_type.rb", "app/graphql/types/#{file_name}_type.rb"

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

                @@attributes_flat << "#{arg.name}:#{arg.type}" + (arg.has_index? ? ":index" : "")

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          template "controllers/scaffold_controller.rb", "app/controllers/#{options.namespace}/#{file_name.pluralize}_controller.rb"

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Block body expression is on the same line as the block start.
    Open

          inject_into_file "app/models/#{file_name}.rb", after: /(ActiveRecord::Base|ApplicationRecord)\n/ do <<-RUBY

    This cop checks whether the multiline do end blocks have a newline after the start of the block. Additionally, it checks whether the block arguments, if any, are on the same line as the start of the block.

    Example:

    # bad
    blah do |i| foo(i)
      bar(i)
    end
    
    # bad
    blah do
      |i| foo(i)
      bar(i)
    end
    
    # good
    blah do |i|
      foo(i)
      bar(i)
    end
    
    # bad
    blah { |i| foo(i)
      bar(i)
    }
    
    # good
    blah { |i|
      foo(i)
      bar(i)
    }

    Line is too long. [109/80]
    Open

        class_option :template, type: :string, default: 'slim', desc: 'Sets the template engine of the generator'

    Line is too long. [102/80]
    Open

                inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do

    Line is too long. [82/80]
    Open

          template "graphql/graphql_type.rb", "app/graphql/types/#{file_name}_type.rb"

    Replace class var @@attribute_names with a class instance var.
    Open

        @@attribute_names = []

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Extra empty line detected at class body end.
    Open

    
      end

    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

    Block body expression is on the same line as the block start.
    Open

            inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do <<-RUBY

    This cop checks whether the multiline do end blocks have a newline after the start of the block. Additionally, it checks whether the block arguments, if any, are on the same line as the start of the block.

    Example:

    # bad
    blah do |i| foo(i)
      bar(i)
    end
    
    # bad
    blah do
      |i| foo(i)
      bar(i)
    end
    
    # good
    blah do |i|
      foo(i)
      bar(i)
    end
    
    # bad
    blah { |i| foo(i)
      bar(i)
    }
    
    # good
    blah { |i|
      foo(i)
      bar(i)
    }

    Line is too long. [100/80]
    Open

              inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do

    Replace class var @@has_position with a class instance var.
    Open

        @@has_position = false

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Replace class var @@display_field with a class instance var.
    Open

            @@display_field = 'name'

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Extra empty line detected at method body end.
    Open

    
        end

    This cops checks if empty lines exist around the bodies of methods.

    Example:

    # good
    
    def foo
      # ...
    end
    
    # bad
    
    def bar
    
      # ...
    
    end

    Line is too long. [93/80]
    Open

                @@attributes_flat << "#{arg.name}:#{arg.type}" + (arg.has_index? ? ":index" : "")

    Line is too long. [128/80]
    Open

          template "controllers/scaffold_controller.rb", "app/controllers/#{options.namespace}/#{file_name.pluralize}_controller.rb"

    Line is too long. [112/80]
    Open

          inject_into_file 'app/models/concerns/fae/navigation_concern.rb', line, before: '# scaffold inject marker'

    Replace class var @@attachments with a class instance var.
    Open

        @@attachments = []

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Space missing inside }.
    Open

          @@attribute_names.delete_if { |i| rejected_attrs.include?(i)}

    Checks that block braces have or don't have surrounding space inside them on configuration. For blocks taking parameters, it checks that the left brace has or doesn't have trailing space depending on configuration.

    Example: EnforcedStyle: space (default)

    # The `space` style enforces that block braces have
    # surrounding space.
    
    # bad
    some_array.each {puts e}
    
    # good
    some_array.each { puts e }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that block braces don't
    # have surrounding space.
    
    # bad
    some_array.each { puts e }
    
    # good
    some_array.each {puts e}

    Example: EnforcedStyleForEmptyBraces: no_space (default)

    # The `no_space` EnforcedStyleForEmptyBraces style enforces that
    # block braces don't have a space in between when empty.
    
    # bad
    some_array.each {   }
    some_array.each {  }
    some_array.each { }
    
    # good
    some_array.each {}

    Example: EnforcedStyleForEmptyBraces: space

    # The `space` EnforcedStyleForEmptyBraces style enforces that
    # block braces have at least a spece in between when empty.
    
    # bad
    some_array.each {}
    
    # good
    some_array.each { }
    some_array.each {  }
    some_array.each {   }

    Example: SpaceBeforeBlockParameters: true (default)

    # The SpaceBeforeBlockParameters style set to `true` enforces that
    # there is a space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each {|n| n * 2 }
    
    # good
    [1, 2, 3].each { |n| n * 2 }

    Example: SpaceBeforeBlockParameters: true

    # The SpaceBeforeBlockParameters style set to `false` enforces that
    # there is no space between `{` and `|`. Overrides `EnforcedStyle`
    # if there is a conflict.
    
    # bad
    [1, 2, 3].each { |n| n * 2 }
    
    # good
    [1, 2, 3].each {|n| n * 2 }

    Method Fae::BaseGenerator#polymorphic_name is defined at both lib/generators/fae/base_generator.rb:213 and lib/generators/fae/base_generator.rb:217.
    Open

        def polymorphic_name

    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

    Line is too long. [150/80]
    Open

        class_option :polymorphic, type: :boolean, default: false, desc: 'Makes the model and scaffolding polymorphic. parent-model is ignored if passed.'

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          inject_into_file "config/routes.rb", after: "namespace :#{options.namespace} do\n", force: true do <<-RUBY

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Line is too long. [135/80]
    Open

          copy_file "views/new.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/new.html.#{options.template}"

    Line is too long. [104/80]
    Open

          inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do <<-RUBY

    Replace class var @@association_names with a class instance var.
    Open

        @@association_names = []

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Block body expression is on the same line as the block start.
    Open

          inject_into_file "app/models/#{file_name}.rb", after: "include Fae::BaseModelConcern\n" do <<-RUBY

    This cop checks whether the multiline do end blocks have a newline after the start of the block. Additionally, it checks whether the block arguments, if any, are on the same line as the start of the block.

    Example:

    # bad
    blah do |i| foo(i)
      bar(i)
    end
    
    # bad
    blah do
      |i| foo(i)
      bar(i)
    end
    
    # good
    blah do |i|
      foo(i)
      bar(i)
    end
    
    # bad
    blah { |i| foo(i)
      bar(i)
    }
    
    # good
    blah { |i|
      foo(i)
      bar(i)
    }

    Line is too long. [141/80]
    Open

          raise "Fae::UnsupportedTemplate: the template engine you defined isn't supported" unless supported_templates.include?(options.template)

    Rename is_association to association?.
    Open

        def is_association(arg)

    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

    Replace class var @@display_field with a class instance var.
    Open

        @@display_field = ''

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Replace class var @@has_position with a class instance var.
    Open

              @@has_position = true if arg.name === 'position'

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Missing top-level class documentation comment.
    Open

      class BaseGenerator < Rails::Generators::NamedBase

    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. [104/80]
    Open

        argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"

    Line is too long. [88/80]
    Open

        Rails::Generators::GeneratedAttribute::DEFAULT_TYPES += ['image', 'file', 'seo_set']

    Replace class var @@attributes_flat with a class instance var.
    Open

            @@attributes_flat = @@attributes_flat.uniq.join(' ')

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Replace class var @@display_field with a class instance var.
    Open

            @@display_field = 'title'

    This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

    Line is too long. [138/80]
    Open

          template "views/_form.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/_form.html.#{options.template}"

    Use %i or %I for an array of symbols.
    Open

          [:image, :file, :seo_set].include?(arg.type)

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    There are no issues that match your filters.

    Category
    Status