3scale/porta

View on GitHub
app/lib/simple_layout.rb

Summary

Maintainability
C
1 day
Test Coverage

Method create_builtin_pages_and_partials! has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_builtin_pages_and_partials!
    p = provider.builtin_pages

    # Shared
    create_builtin_partial!('field')
Severity: Major
Found in app/lib/simple_layout.rb - About 3 hrs to fix

    File simple_layout.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'sprockets'
    require 'compass-rails'
    require 'sass'
    
    class SimpleLayout
    Severity: Minor
    Found in app/lib/simple_layout.rb - About 2 hrs to fix

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

      class SimpleLayout
      
        attr_reader :provider
      
        def initialize(provider)
      Severity: Minor
      Found in app/lib/simple_layout.rb - About 2 hrs to fix

        SimpleLayout#build_builtin_static_page refers to 'attributes' more than self (maybe move it to another class?)
        Open

              l.system_name = attributes[:system_name]
              l.section = attributes[:section]
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

        Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

        Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

        Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

        Example

        Running Reek on:

        class Warehouse
          def sale_price(item)
            (item.price - item.rebate) * @vat
          end
        end

        would report:

        Warehouse#total_price refers to item more than self (FeatureEnvy)

        since this:

        (item.price - item.rebate)

        belongs to the Item class, not the Warehouse.

        SimpleLayout#create_builtin_partial! refers to 'p' more than self (maybe move it to another class?)
        Open

                p.system_name = system_name
                p.draft = CMS::Builtin::Partial.filesystem_templates.fetch(system_name).read
                p.liquid_enabled = true
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

        Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

        Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

        Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

        Example

        Running Reek on:

        class Warehouse
          def sale_price(item)
            (item.price - item.rebate) * @vat
          end
        end

        would report:

        Warehouse#total_price refers to item more than self (FeatureEnvy)

        since this:

        (item.price - item.rebate)

        belongs to the Item class, not the Warehouse.

        SimpleLayout#build_builtin_static_page refers to 'l' more than self (maybe move it to another class?)
        Open

              l.system_name = attributes[:system_name]
              l.section = attributes[:section]
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

        Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

        Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

        Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

        Example

        Running Reek on:

        class Warehouse
          def sale_price(item)
            (item.price - item.rebate) * @vat
          end
        end

        would report:

        Warehouse#total_price refers to item more than self (FeatureEnvy)

        since this:

        (item.price - item.rebate)

        belongs to the Item class, not the Warehouse.

        SimpleLayout#create_builtin_pages_and_partials! has approx 72 statements
        Open

          def create_builtin_pages_and_partials!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

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

        SimpleLayout has at least 21 methods
        Open

        class SimpleLayout
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        Too Many Methods is a special case of LargeClass.

        Example

        Given this configuration

        TooManyMethods:
          max_methods: 3

        and this code:

        class TooManyMethods
          def one; end
          def two; end
          def three; end
          def four; end
        end

        Reek would emit the following warning:

        test.rb -- 1 warning:
          [1]:TooManyMethods has at least 4 methods (TooManyMethods)

        SimpleLayout#import_js_and_css! has approx 14 statements
        Open

          def import_js_and_css!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

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

        SimpleLayout#import! has approx 9 statements
        Open

          def import! # _all
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

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

        SimpleLayout#setup_main_layout! calls 'provider.layouts' 2 times
        Open

            provider.layouts.find_by_system_name("main_layout") || begin
              content = DeveloperPortal::VIEW_PATH.join('layouts/main_layout.html.liquid').read
              provider.layouts.create!(system_name: 'main_layout',
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        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.

        SimpleLayout#create_service_plans_builtin_pages! calls '@provider.builtin_pages' 2 times
        Open

            @provider.builtin_pages.find_or_create! 'services/new', 'Subscribe to a service', section
            @provider.builtin_pages.find_or_create! 'services/index', 'List services', section
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        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.

        SimpleLayout#import_pages! calls 'provider.pages' 4 times
        Open

            provider.pages.find_by_path('/') ||
              provider.pages.build(title: 'Homepage',
                                   path: '/',
                                   liquid_enabled: true,
                                   section: root,
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        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.

        SimpleLayout#create_builtin_pages_and_partials! calls 'provider.settings' 2 times
        Open

            if provider.settings.multiple_applications.allowed?
              p.find_or_create! 'applications/new', 'New Application', apps
            end
        
            if provider.multiservice?
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        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.

        SimpleLayout#create_builtin_partial! calls 'provider.builtin_partials' 2 times
        Open

            unless provider.builtin_partials.find_by_system_name(system_name)
              provider.builtin_partials.create! do |p|
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        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.

        SimpleLayout has missing safe method 'create_builtin_pages_and_partials!'
        Open

          def create_builtin_pages_and_partials!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'create_builtin_partial!'
        Open

          def create_builtin_partial!(system_name)
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'create_multiservice_builtin_pages!'
        Open

          def create_multiservice_builtin_pages!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'import!'
        Open

          def import! # _all
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'update_error_layout!'
        Open

          def update_error_layout!(error_layout)
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'setup_error_layout!'
        Open

          def setup_error_layout!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'setup_main_layout!'
        Open

          def setup_main_layout!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'import_js_and_css!'
        Open

          def import_js_and_css!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout#update_error_layout! doesn't depend on instance state (maybe move it to another class?)
        Open

          def update_error_layout!(error_layout)
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A Utility Function is any instance method that has no dependency on the state of the instance.

        SimpleLayout has missing safe method 'create_service_plans_builtin_pages!'
        Open

          def create_service_plans_builtin_pages!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'create_multiapp_builtin_pages!'
        Open

          def create_multiapp_builtin_pages!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'import_static_pages!'
        Open

          def import_static_pages!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'import_images!'
        Open

          def import_images!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'import_pages!'
        Open

          def import_pages!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout has missing safe method 'create_error_layout!'
        Open

          def create_error_layout!
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

        An exclamation mark in method names means (the explanation below is taken from here ):

        The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

        Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

        Example

        Given

        class C
          def foo; end
          def foo!; end
          def bar!; end
        end

        Reek would report bar! as Missing Safe Method smell but not foo!.

        Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

        class Parent
          def foo; end
        end
        
        module Dangerous
          def foo!; end
        end
        
        class Son < Parent
          include Dangerous
        end
        
        class Daughter < Parent
        end

        In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

        SimpleLayout#build_builtin_static_page has the variable name 'l'
        Open

            provider.builtin_static_pages.build do |l|
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

        Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

        SimpleLayout#create_builtin_pages_and_partials! has the variable name 'p'
        Open

            p = provider.builtin_pages
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

        Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

        SimpleLayout#create_builtin_partial! has the variable name 'p'
        Open

              provider.builtin_partials.create! do |p|
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

        Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

        SimpleLayout#setup_main_layout! has the variable name 'p'
        Open

                                       liquid_enabled: true).tap { |p| p.publish! }
        Severity: Minor
        Found in app/lib/simple_layout.rb by reek

        An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

        Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

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

            provider.pages.find_by_path('/') ||
              provider.pages.build(title: 'Homepage',
                                   path: '/',
                                   liquid_enabled: true,
                                   section: root,
        Severity: Minor
        Found in app/lib/simple_layout.rb and 1 other location - About 20 mins to fix
        app/lib/simple_layout.rb on lines 31..39

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

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            provider.pages.find_by_path('/docs') ||
              provider.pages.build(title: 'Documentation',
                                   path: '/docs',
                                   liquid_enabled: true,
                                   section: root,
        Severity: Minor
        Found in app/lib/simple_layout.rb and 1 other location - About 20 mins to fix
        app/lib/simple_layout.rb on lines 21..29

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

        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

        There are no issues that match your filters.

        Category
        Status