uptech/togls

View on GitHub

Showing 195 of 195 total issues

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

    def reconstitute_toggle(toggle_data)
      begin
        feature = @feature_repository.get(toggle_data['feature_id'])
      rescue Togls::RepositoryFeatureDataInvalid => e
        return Togls::NullToggle.new
Severity: Minor
Found in lib/togls/toggle_repository.rb by rubocop

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

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

    def validate_rule_data(rule_data)
      if rule_data.nil?
        Togls.logger.warn "None of the rule repository drivers claim to have the rule"
        raise Togls::RepositoryRuleDataInvalid, "None of the rule repository drivers claim to have the rule"
      end
Severity: Minor
Found in lib/togls/rule_repository.rb by rubocop

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

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

    def validate_feature_data(feature_data)
      if feature_data.nil?
        Togls.logger.warn("None of the feature repository drivers claim to have the feature")
        raise Togls::RepositoryFeatureDataInvalid, "None of the feature repository drivers claim to have the feature"
      end
Severity: Minor
Found in lib/togls/feature_repository.rb by rubocop

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

Assignment Branch Condition size for reconstitute_rule is too high. [19.03/15]
Open

    def reconstitute_rule(rule_data)
      if rule_data.has_key?('target_type')
        ::Togls.rule_type(rule_data['type_id'])\
          .new(rule_data['id'].to_sym, rule_data['type_id'].to_sym, rule_data['data'],
               target_type: rule_data['target_type'].to_sym)
Severity: Minor
Found in lib/togls/rule_repository.rb by rubocop

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

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

      def default_feature_target_type(target_type = nil)
        if target_type
          if @default_feature_target_type
            raise Togls::DefaultFeatureTargetTypeAlreadySet, 'the default feature target type has already been set'
          else

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 target_matches? is too high. [18.44/15]
Open

    def target_matches?(rule)
      if rule.target_type == Togls::TargetTypes::NONE
        return true
      elsif rule.target_type == Togls::TargetTypes::NOT_SET
        Togls.logger.warn "Rule (id: #{rule.id}) cannot have target type of :not_set"
Severity: Minor
Found in lib/togls/toggle.rb by rubocop

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

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

      def self.description
        %Q{
The Group rule allows you to define an arbitrary collection of objects to be
used in evaluating against the target. Specify the initialization data as an
array of inclusive identifiers for the group. When the feature toggle is
Severity: Minor
Found in lib/togls/rules/group.rb by rubocop

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

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

    def target_matches?(rule)
      if rule.target_type == Togls::TargetTypes::NONE
        return true
      elsif rule.target_type == Togls::TargetTypes::NOT_SET
        Togls.logger.warn "Rule (id: #{rule.id}) cannot have target type of :not_set"
Severity: Minor
Found in lib/togls/toggle.rb by rubocop

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

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

      def test_toggle_registry
        feature_repository_drivers =
          [Togls::FeatureRepositoryDrivers::InMemoryDriver.new]
        test_feature_repository = Togls::FeatureRepository.new(
          feature_repository_drivers)

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

    def validate_rule_data(rule_data)
      if rule_data.nil?
        Togls.logger.warn "None of the rule repository drivers claim to have the rule"
        raise Togls::RepositoryRuleDataInvalid, "None of the rule repository drivers claim to have the rule"
      end
Severity: Minor
Found in lib/togls/rule_repository.rb by rubocop

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

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

    def validate_target(target)
      is_explicit_target_type = @feature.target_type != Togls::TargetTypes::NONE &&
        @feature.target_type != Togls::TargetTypes::NOT_SET &&
        @feature.target_type != Togls::TargetTypes::EITHER
      if @feature.target_type == Togls::TargetTypes::NONE && target
Severity: Minor
Found in lib/togls/toggle.rb by rubocop

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

Assignment Branch Condition size for validate_feature_data is too high. [16.28/15]
Open

    def validate_feature_data(feature_data)
      if feature_data.nil?
        Togls.logger.warn("None of the feature repository drivers claim to have the feature")
        raise Togls::RepositoryFeatureDataInvalid, "None of the feature repository drivers claim to have the feature"
      end
Severity: Minor
Found in lib/togls/feature_repository.rb by rubocop

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

Cyclomatic complexity for validate_target is too high. [7/6]
Open

    def validate_target(target)
      is_explicit_target_type = @feature.target_type != Togls::TargetTypes::NONE &&
        @feature.target_type != Togls::TargetTypes::NOT_SET &&
        @feature.target_type != Togls::TargetTypes::EITHER
      if @feature.target_type == Togls::TargetTypes::NONE && target
Severity: Minor
Found in lib/togls/toggle.rb by rubocop

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.

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

      def release_toggle_registry
        if @release_toggle_registry.nil?

          toggle_repository_drivers = [
            Togls::ToggleRepositoryDrivers::InMemoryDriver.new,

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

    def reconstitute_toggle(toggle_data)
      begin
        feature = @feature_repository.get(toggle_data['feature_id'])
      rescue Togls::RepositoryFeatureDataInvalid => e
        return Togls::NullToggle.new
Severity: Minor
Found in lib/togls/toggle_repository.rb by rubocop

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

Assignment Branch Condition size for get is too high. [15.3/15]
Open

      def get(toggle_id)
        return nil if ENV[toggle_env_key(toggle_id)].nil?
        if ENV[toggle_env_key(toggle_id)] == 'true'
          return { 'feature_id' => toggle_id, 'rule_id' =>
                   Togls::Rules::Boolean.new(:on, :boolean, true).id.to_s }

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 store has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def store(type_id, klass_str, title, description, target_type)
Severity: Minor
Found in lib/togls/rule_type_repository_drivers/in_memory_driver.rb - About 35 mins to fix

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

    module Togls
      module RuleRepositoryDrivers
        # Rule Repository In-Memory Driver
        #
        # The Rule Repository In-Memory Driver provides the interface to store and
    Severity: Minor
    Found in lib/togls/rule_repository_drivers/in_memory_driver.rb and 2 other locations - About 35 mins to fix
    lib/togls/feature_repository_drivers/in_memory_driver.rb on lines 3..26
    lib/togls/toggle_repository_drivers/in_memory_driver.rb on lines 3..26

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

    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 3 locations. Consider refactoring.
    Open

    module Togls
      module FeatureRepositoryDrivers
        # Feature Repository In-Memory Driver
        #
        # The Feature Repository In-Memory Driver provides the facility to store and
    Severity: Minor
    Found in lib/togls/feature_repository_drivers/in_memory_driver.rb and 2 other locations - About 35 mins to fix
    lib/togls/rule_repository_drivers/in_memory_driver.rb on lines 3..26
    lib/togls/toggle_repository_drivers/in_memory_driver.rb on lines 3..26

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

    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 3 locations. Consider refactoring.
    Open

    module Togls
      module ToggleRepositoryDrivers
        # Toggle Repositoy In-Memory Driver
        #
        # The Toggle Repository In-Memory Driver provides the interface to store and
    Severity: Minor
    Found in lib/togls/toggle_repository_drivers/in_memory_driver.rb and 2 other locations - About 35 mins to fix
    lib/togls/feature_repository_drivers/in_memory_driver.rb on lines 3..26
    lib/togls/rule_repository_drivers/in_memory_driver.rb on lines 3..26

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

    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

    Severity
    Category
    Status
    Source
    Language