ikuseiGmbH/Goldencobra

View on GitHub
lib/generators/goldencobra/install_generator.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      desc "Creates active_admin initializer, routes and copy locale files to your application."
      class_option :orm

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

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

      def install_capistrano
        if yes?("Would you like to configure git?")
          @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
          git :init
          git remote: "add origin #{@git_url}"

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

      def install_capistrano
        if yes?("Would you like to configure git?")
          @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
          git :init
          git remote: "add origin #{@git_url}"

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 install_test_env
        if yes?("Would you like to install a test Environment")
          gem("rspec-rails", '~> 2.12.2', group: "test")
          gem("annotate", group: "test")
          gem("ruby-graphviz", group: "test")

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.

Complex method Goldencobra::Generators::InstallGenerator#install_capistrano (53.4)
Open

      def install_capistrano
        if yes?("Would you like to configure git?")
          @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
          git :init
          git remote: "add origin #{@git_url}"

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Assignment Branch Condition size for install_test_env is too high. [23.02/15]
Open

      def install_test_env
        if yes?("Would you like to install a test Environment")
          gem("rspec-rails", '~> 2.12.2', group: "test")
          gem("annotate", group: "test")
          gem("ruby-graphviz", group: "test")

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

      def create_admin_user_password
        @admin_email = ask("Please enter a email for your admin account (default: admin@goldencobra.de):")
        @admin_email = "admin@goldencobra.de" if @admin_email.blank?

        @admin_password = ask("Please enter a new password for admin account (user: #{@admin_email}):")

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.

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

      def install_capistrano
        if yes?("Would you like to configure git?")
          @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
          git :init
          git remote: "add origin #{@git_url}"

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.

Perceived complexity for install_capistrano is too high. [8/7]
Open

      def install_capistrano
        if yes?("Would you like to configure git?")
          @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
          git :init
          git remote: "add origin #{@git_url}"

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

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

      def install_capistrano
        if yes?("Would you like to configure git?")
          @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
          git :init
          git remote: "add origin #{@git_url}"
Severity: Minor
Found in lib/generators/goldencobra/install_generator.rb - About 1 hr to fix

    Method install_capistrano has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def install_capistrano
            if yes?("Would you like to configure git?")
              @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
              git :init
              git remote: "add origin #{@git_url}"
    Severity: Minor
    Found in lib/generators/goldencobra/install_generator.rb - About 1 hr 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

    Complex method Goldencobra::Generators::InstallGenerator#install_test_env (29.7)
    Open

          def install_test_env
            if yes?("Would you like to install a test Environment")
              gem("rspec-rails", '~> 2.12.2', group: "test")
              gem("annotate", group: "test")
              gem("ruby-graphviz", group: "test")

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Goldencobra::Generators::InstallGenerator#install_capistrano has approx 28 statements
    Open

          def install_capistrano

    A method with Too Many Statements is any method that has a large number of lines.

    Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

    So the following method would score +6 in Reek's statement-counting algorithm:

    def parse(arg, argv, &error)
      if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
        return nil, block, nil                                         # +1
      end
      opt = (val = parse_arg(val, &error))[1]                          # +2
      val = conv_arg(*val)                                             # +3
      if opt and !arg
        argv.shift                                                     # +4
      else
        val[0] = nil                                                   # +5
      end
      val                                                              # +6
    end

    (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

    Goldencobra::Generators::InstallGenerator has at least 11 instance variables
    Open

        class InstallGenerator < Rails::Generators::Base

    Too Many Instance Variables is a special case of LargeClass.

    Example

    Given this configuration

    TooManyInstanceVariables:
      max_instance_variables: 3

    and this code:

    class TooManyInstanceVariables
      def initialize
        @arg_1 = :dummy
        @arg_2 = :dummy
        @arg_3 = :dummy
        @arg_4 = :dummy
      end
    end

    Reek would emit the following warning:

    test.rb -- 5 warnings:
      [1]:TooManyInstanceVariables has at least 4 instance variables (TooManyInstanceVariables)

    Goldencobra::Generators::InstallGenerator#create_admin_user_password has approx 9 statements
    Open

          def create_admin_user_password

    A method with Too Many Statements is any method that has a large number of lines.

    Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

    So the following method would score +6 in Reek's statement-counting algorithm:

    def parse(arg, argv, &error)
      if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
        return nil, block, nil                                         # +1
      end
      opt = (val = parse_arg(val, &error))[1]                          # +2
      val = conv_arg(*val)                                             # +3
      if opt and !arg
        argv.shift                                                     # +4
      else
        val[0] = nil                                                   # +5
      end
      val                                                              # +6
    end

    (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

    Goldencobra::Generators::InstallGenerator#install_errbit has approx 9 statements
    Open

          def install_errbit

    A method with Too Many Statements is any method that has a large number of lines.

    Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

    So the following method would score +6 in Reek's statement-counting algorithm:

    def parse(arg, argv, &error)
      if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
        return nil, block, nil                                         # +1
      end
      opt = (val = parse_arg(val, &error))[1]                          # +2
      val = conv_arg(*val)                                             # +3
      if opt and !arg
        argv.shift                                                     # +4
      else
        val[0] = nil                                                   # +5
      end
      val                                                              # +6
    end

    (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

    Goldencobra::Generators::InstallGenerator#modify_application_rb has approx 8 statements
    Open

          def modify_application_rb

    A method with Too Many Statements is any method that has a large number of lines.

    Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

    So the following method would score +6 in Reek's statement-counting algorithm:

    def parse(arg, argv, &error)
      if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
        return nil, block, nil                                         # +1
      end
      opt = (val = parse_arg(val, &error))[1]                          # +2
      val = conv_arg(*val)                                             # +3
      if opt and !arg
        argv.shift                                                     # +4
      else
        val[0] = nil                                                   # +5
      end
      val                                                              # +6
    end

    (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

    Goldencobra::Generators::InstallGenerator#install_assets has approx 8 statements
    Open

          def install_assets

    A method with Too Many Statements is any method that has a large number of lines.

    Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

    So the following method would score +6 in Reek's statement-counting algorithm:

    def parse(arg, argv, &error)
      if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
        return nil, block, nil                                         # +1
      end
      opt = (val = parse_arg(val, &error))[1]                          # +2
      val = conv_arg(*val)                                             # +3
      if opt and !arg
        argv.shift                                                     # +4
      else
        val[0] = nil                                                   # +5
      end
      val                                                              # +6
    end

    (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

    Goldencobra::Generators::InstallGenerator#install_test_env has approx 22 statements
    Open

          def install_test_env

    A method with Too Many Statements is any method that has a large number of lines.

    Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

    So the following method would score +6 in Reek's statement-counting algorithm:

    def parse(arg, argv, &error)
      if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
        return nil, block, nil                                         # +1
      end
      opt = (val = parse_arg(val, &error))[1]                          # +2
      val = conv_arg(*val)                                             # +3
      if opt and !arg
        argv.shift                                                     # +4
      else
        val[0] = nil                                                   # +5
      end
      val                                                              # +6
    end

    (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@app_name'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator has no descriptive comment
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

    Example

    Given

    class Dummy
      # Do things...
    end

    Reek would emit the following warning:

    test.rb -- 1 warning:
      [1]:Dummy has no descriptive comment (IrresponsibleModule)

    Fixing this is simple - just an explaining comment:

    # The Dummy class is responsible for ...
    class Dummy
      # Do things...
    end

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@admin_email'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator#modify_application_rb calls 'Regexp.escape(line)' 2 times
    Open

            gsub_file 'config/application.rb', /(#{Regexp.escape(line)})/mi do |match|
              "config.active_record.whitelist_attributes = false"
            end
    
            line = "class Application < Rails::Application"

    Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

    Reek implements a check for Duplicate Method Call.

    Example

    Here's a very much simplified and contrived example. The following method will report a warning:

    def double_thing()
      @other.thing + @other.thing
    end

    One quick approach to silence Reek would be to refactor the code thus:

    def double_thing()
      thing = @other.thing
      thing + thing
    end

    A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

    class Other
      def double_thing()
        thing + thing
      end
    end

    The approach you take will depend on balancing other factors in your code.

    Goldencobra::Generators::InstallGenerator#install_capistrano calls 'ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")' 2 times
    Open

              @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
              git :init
              git remote: "add origin #{@git_url}"
              git add: "."
              git commit: "-m 'First commit'"

    Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

    Reek implements a check for Duplicate Method Call.

    Example

    Here's a very much simplified and contrived example. The following method will report a warning:

    def double_thing()
      @other.thing + @other.thing
    end

    One quick approach to silence Reek would be to refactor the code thus:

    def double_thing()
      thing = @other.thing
      thing + thing
    end

    A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

    class Other
      def double_thing()
        thing + thing
      end
    end

    The approach you take will depend on balancing other factors in your code.

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@git_url'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@host'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator#install_capistrano calls 'git push: "origin master"' 3 times
    Open

              git push: "origin master"
            end
            if yes?("Would you like to configure capistrano? (a git repository is required)")
              @ip_address = ask("To which IP do you want to deploy? (bsp: Taurus 178.23.121.27)")
              if @git_url.blank?

    Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

    Reek implements a check for Duplicate Method Call.

    Example

    Here's a very much simplified and contrived example. The following method will report a warning:

    def double_thing()
      @other.thing + @other.thing
    end

    One quick approach to silence Reek would be to refactor the code thus:

    def double_thing()
      thing = @other.thing
      thing + thing
    end

    A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

    class Other
      def double_thing()
        thing + thing
      end
    end

    The approach you take will depend on balancing other factors in your code.

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@port'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator#install_capistrano calls 'git add: "."' 3 times
    Open

              git add: "."
              git commit: "-m 'First commit'"
              git push: "origin master"
            end
            if yes?("Would you like to configure capistrano? (a git repository is required)")

    Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

    Reek implements a check for Duplicate Method Call.

    Example

    Here's a very much simplified and contrived example. The following method will report a warning:

    def double_thing()
      @other.thing + @other.thing
    end

    One quick approach to silence Reek would be to refactor the code thus:

    def double_thing()
      thing = @other.thing
      thing + thing
    end

    A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

    class Other
      def double_thing()
        thing + thing
      end
    end

    The approach you take will depend on balancing other factors in your code.

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@api_key'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@ruby_version'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

    Goldencobra::Generators::InstallGenerator assumes too much for instance variable '@license_key'
    Open

        class InstallGenerator < Rails::Generators::Base

    Classes should not assume that instance variables are set or present outside of the current class definition.

    Good:

    class Foo
      def initialize
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Good as well:

    class Foo
      def foo?
        bar == :foo
      end
    
      def bar
        @bar ||= :foo
      end
    end

    Bad:

    class Foo
      def go_foo!
        @bar = :foo
      end
    
      def foo?
        @bar == :foo
      end
    end

    Example

    Running Reek on:

    class Dummy
      def test
        @ivar
      end
    end

    would report:

    [1]:InstanceVariableAssumption: Dummy assumes too much for instance variable @ivar

    Note that this example would trigger this smell warning as well:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        @omg
      end
    end

    The way to address the smell warning is that you should create an attr_reader to use @omg in the subclass and not access @omg directly like this:

    class Parent
      attr_reader :omg
    
      def initialize(omg)
        @omg = omg
      end
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Directly accessing instance variables is considered a smell because it breaks encapsulation and makes it harder to reason about code.

    If you don't want to expose those methods as public API just make them private like this:

    class Parent
      def initialize(omg)
        @omg = omg
      end
    
      private
      attr_reader :omg
    end
    
    class Child < Parent
      def foo
        omg
      end
    end

    Current Support in Reek

    An instance variable must:

    • be set in the constructor
    • or be accessed through a method with lazy initialization / memoization.

    If not, Instance Variable Assumption will be reported.

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

            if yes?("Would you like to configure capistrano? (a git repository is required)")
              @ip_address = ask("To which IP do you want to deploy? (bsp: Taurus 178.23.121.27)")
              if @git_url.blank?
                @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
              end
    Severity: Minor
    Found in lib/generators/goldencobra/install_generator.rb and 1 other location - About 40 mins to fix
    lib/generators/goldencobra/server_generator.rb on lines 20..34

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

    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

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

            if yes?("Would you like to configure git?")
              @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")
              git :init
              git remote: "add origin #{@git_url}"
              git add: "."
    Severity: Minor
    Found in lib/generators/goldencobra/install_generator.rb and 1 other location - About 20 mins to fix
    lib/generators/goldencobra/server_generator.rb on lines 12..19

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

    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. [103/100]
    Open

            @admin_password = ask("Please enter a new password for admin account (user: #{@admin_email}):")

    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.

    Literal " require 'pdfkit'" used in void context.
    Open

              "  require 'pdfkit'"

    This cop checks for operators, variables, literals, and nonmutating methods used in void context.

    Example:

    # bad
    
    def some_method
      some_num * 10
      do_something
    end

    Example:

    # bad
    
    def some_method(some_var)
      some_var
      do_something
    end

    Example:

    # bad, when CheckForMethodsWithNoSideEffects is set true
    
    def some_method(some_array)
      some_array.sort
      do_something(some_array)
    end

    Example:

    # good
    
    def some_method
      do_something
      some_num * 10
    end

    Example:

    # good
    
    def some_method(some_var)
      do_something
      some_var
    end

    Example:

    # good, when CheckForMethodsWithNoSideEffects is set true
    
    def some_method(some_array)
      some_array.sort!
      do_something(some_array)
    end

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

              if yes?("Would you like to create remote database?")

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Unused block argument - match. You can omit the argument if you don't care about it.
    Open

            gsub_file 'config/application.rb', /(#{Regexp.escape(line)})/mi do |match|

    This cop checks for unused block arguments.

    Example:

    # bad
    
    do_something do |used, unused|
      puts used
    end
    
    do_something do |bar|
      puts :foo
    end
    
    define_method(:foo) do |bar|
      puts :baz
    end

    Example:

    #good
    
    do_something do |used, _unused|
      puts used
    end
    
    do_something do
      puts :foo
    end
    
    define_method(:foo) do |_bar|
      puts :baz
    end

    Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              copy_file '../templates/database.yml.erb', 'config/templates/database.yml.erb'

    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 double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              template '../templates/apache.tmpl.erb', "config/templates/#{@app_name}"

    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 double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

            gsub_file 'config/application.rb', /(#{Regexp.escape(line)})/mi do |match|

    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. [106/100]
    Open

            @admin_email = ask("Please enter a email for your admin account (default: admin@goldencobra.de):")

    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.

    Unused block argument - match. You can omit the argument if you don't care about it.
    Open

            gsub_file "config/environments/production.rb", /(#{Regexp.escape(line)})/mi do |match|

    This cop checks for unused block arguments.

    Example:

    # bad
    
    do_something do |used, unused|
      puts used
    end
    
    do_something do |bar|
      puts :foo
    end
    
    define_method(:foo) do |bar|
      puts :baz
    end

    Example:

    #good
    
    do_something do |used, _unused|
      puts used
    end
    
    do_something do
      puts :foo
    end
    
    define_method(:foo) do |_bar|
      puts :baz
    end

    Line is too long. [118/100]
    Open

              @license_key = ask("What is your NewRelic license key? (default: b199ad3e4e0d728b1aac69aec4870af7ef9478bb)")

    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.

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

            if yes?("Would you like to configure a .rvmrc file?")

    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

    Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              gem("rspec-rails", '~> 2.12.2', group: "test")

    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. [106/100]
    Open

              copy_file '../templates/create_database.mysql.erb', 'config/templates/create_database.mysql.erb'

    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.

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

            if yes?("Would you like to migrate your local db?")

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

            if yes?("Would you like to seed your local db?")

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Missing space after #.
    Open

              #Add Changes to git

    This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

    Example:

    # bad
    #Some comment
    
    # good
    # Some comment

    Missing space after #.
    Open

              #Add Changes to git

    This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

    Example:

    # bad
    #Some comment
    
    # good
    # Some comment

    Use compact module/class definition instead of nested style.
    Open

      module Generators

    This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

    Example: EnforcedStyle: nested (default)

    # good
    # have each child on its own line
    class Foo
      class Bar
      end
    end

    Example: EnforcedStyle: compact

    # good
    # combine definitions as much as possible
    class Foo::Bar
    end

    The compact style is only forced for classes/modules with one child.

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

              if yes?("Would you like to seed your remote db?")

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              copy_file '../templates/create_database.mysql.erb', 'config/templates/create_database.mysql.erb'

    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 double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              copy_file '../templates/create_database.mysql.erb', 'config/templates/create_database.mysql.erb'

    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 a guard clause instead of wrapping the code inside a conditional expression.
    Open

            if yes?("Would you like to install a test Environment")

    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

    Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              copy_file '../templates/database.yml.erb', 'config/templates/database.yml.erb'

    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 expand_path('templates', __dir__) instead of expand_path('../templates', __FILE__).
    Open

          source_root File.expand_path("../templates", __FILE__)

    This cop checks for use of the File.expand_path arguments. Likewise, it also checks for the Pathname.new argument.

    Contrastive bad case and good case are alternately shown in the following examples.

    Example:

    # bad
    File.expand_path('..', __FILE__)
    
    # good
    File.expand_path(__dir__)
    
    # bad
    File.expand_path('../..', __FILE__)
    
    # good
    File.expand_path('..', __dir__)
    
    # bad
    File.expand_path('.', __FILE__)
    
    # good
    File.expand_path(__FILE__)
    
    # bad
    Pathname(__FILE__).parent.expand_path
    
    # good
    Pathname(__dir__).expand_path
    
    # bad
    Pathname.new(__FILE__).parent.expand_path
    
    # good
    Pathname.new(__dir__).expand_path

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

            if yes?("Would you like to install NewRelic? (www.newrelic.com)")

    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

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

            if yes?("Would you like to configure your server and deploy to it?")

    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

    Literal "class Application < Rails::Application" used in void context.
    Open

              "class Application < Rails::Application"

    This cop checks for operators, variables, literals, and nonmutating methods used in void context.

    Example:

    # bad
    
    def some_method
      some_num * 10
      do_something
    end

    Example:

    # bad
    
    def some_method(some_var)
      some_var
      do_something
    end

    Example:

    # bad, when CheckForMethodsWithNoSideEffects is set true
    
    def some_method(some_array)
      some_array.sort
      do_something(some_array)
    end

    Example:

    # good
    
    def some_method
      do_something
      some_num * 10
    end

    Example:

    # good
    
    def some_method(some_var)
      do_something
      some_var
    end

    Example:

    # good, when CheckForMethodsWithNoSideEffects is set true
    
    def some_method(some_array)
      some_array.sort!
      do_something(some_array)
    end

    Line is too long. [184/100]
    Open

              system("/bin/bash -ce '[[ -s \"$HOME/.rvm/scripts/rvm\" ]] && source \"$HOME/.rvm/scripts/rvm\" && rvm use #{@ruby_version}@#{Rails.application.class.parent_name} --create'")

    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.

    Unused block argument - match. You can omit the argument if you don't care about it.
    Open

            gsub_file "config/environments/production.rb", /(#{Regexp.escape(line)})/mi do |match|

    This cop checks for unused block arguments.

    Example:

    # bad
    
    do_something do |used, unused|
      puts used
    end
    
    do_something do |bar|
      puts :foo
    end
    
    define_method(:foo) do |bar|
      puts :baz
    end

    Example:

    #good
    
    do_something do |used, _unused|
      puts used
    end
    
    do_something do
      puts :foo
    end
    
    define_method(:foo) do |_bar|
      puts :baz
    end

    Use compact module/class definition instead of nested style.
    Open

    module Goldencobra

    This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

    Example: EnforcedStyle: nested (default)

    # good
    # have each child on its own line
    class Foo
      class Bar
      end
    end

    Example: EnforcedStyle: compact

    # good
    # combine definitions as much as possible
    class Foo::Bar
    end

    The compact style is only forced for classes/modules with one child.

    Use 2 (not 4) spaces for indentation.
    Open

              gem("airbrake")

    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

    Line is too long. [105/100]
    Open

                @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")

    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.

    Missing top-level class documentation comment.
    Open

        class InstallGenerator < Rails::Generators::Base

    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

    Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
    Open

              gem("rb-fsevent", '~> 0.9.1', group: "test")

    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. [103/100]
    Open

              @git_url = ask("What is your git url? (bsp: ssh://git@git.ikusei.de:7999/KLIMA/website.git)")

    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.

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

            if yes?("Would you like to seed your local db?")

    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

    Use expand_path('templates', __dir__) instead of expand_path('../templates', __FILE__).
    Open

            File.expand_path("../templates", __FILE__)

    This cop checks for use of the File.expand_path arguments. Likewise, it also checks for the Pathname.new argument.

    Contrastive bad case and good case are alternately shown in the following examples.

    Example:

    # bad
    File.expand_path('..', __FILE__)
    
    # good
    File.expand_path(__dir__)
    
    # bad
    File.expand_path('../..', __FILE__)
    
    # good
    File.expand_path('..', __dir__)
    
    # bad
    File.expand_path('.', __FILE__)
    
    # good
    File.expand_path(__FILE__)
    
    # bad
    Pathname(__FILE__).parent.expand_path
    
    # good
    Pathname(__dir__).expand_path
    
    # bad
    Pathname.new(__FILE__).parent.expand_path
    
    # good
    Pathname.new(__dir__).expand_path

    There are no issues that match your filters.

    Category
    Status