cucumber/cucumber-ruby-core

Identical code found in 2 other locations

# frozen_string_literal: true
module Cucumber
  module Core
    module Ast
      module Names
lib/cucumber/core/ast/outline_step.rb on lines 24..26
lib/cucumber/core/ast/step.rb on lines 38..40

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

Refactorings

Further Reading

Identical code found in 2 other locations

# frozen_string_literal: true
require 'cucumber/core/ast/location'
require 'cucumber/core/ast/describes_itself'
require 'cucumber/core/ast/step'

lib/cucumber/core/ast/names.rb on lines 18..20
lib/cucumber/core/ast/step.rb on lines 38..40

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

Refactorings

Further Reading

Identical code found in 2 other locations

# frozen_string_literal: true
require 'cucumber/core/ast/describes_itself'
require 'cucumber/core/ast/location'

module Cucumber
lib/cucumber/core/ast/names.rb on lines 18..20
lib/cucumber/core/ast/outline_step.rb on lines 24..26

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

Refactorings

Further Reading

Complex method in .new

      def self.new(*attributes)
        # Use normal constructor for subclasses of Event
        return super if self.ancestors.index(Event) > 0

        Class.new(Event) do

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/ast'
require 'cucumber/core/platform'

module Cucumber
lib/cucumber/core/gherkin/ast_builder.rb on lines 64..68

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

Refactorings

Further Reading

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/ast'
require 'cucumber/core/platform'

module Cucumber
lib/cucumber/core/gherkin/ast_builder.rb on lines 111..115

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

Refactorings

Further Reading

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/gherkin/writer/helpers'
require 'cucumber/core/gherkin/document'

module Cucumber
lib/cucumber/core/gherkin/writer.rb on lines 76..88

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

Refactorings

Further Reading

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/gherkin/writer/helpers'
require 'cucumber/core/gherkin/document'

module Cucumber
lib/cucumber/core/gherkin/writer.rb on lines 92..107

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

Refactorings

Further Reading

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/test/case'
require 'cucumber/core/test/step'

module Cucumber
lib/cucumber/core/compiler.rb on lines 143..154

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

Refactorings

Further Reading

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/test/case'
require 'cucumber/core/test/step'

module Cucumber
lib/cucumber/core/compiler.rb on lines 159..170

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

Refactorings

Further Reading

Complex method in #element

            def element(name)
              define_method name do |*args, &source|
                factory_name = String(name).split("_").map(&:capitalize).join
                factory = Writer.const_get(factory_name)
                factory.new(slurp_comments, *args).tap do |builder|

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in .level

          def self.level(number)
            Module.new do
              define_method :indent do |string, amount=nil|
                amount ||= number
                return string if string.nil? || string.empty?

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in .new

      def self.new(*attributes, &block)
        attributes << :receiver

        result = Class.new do
          attr_reader(*attributes)

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/ast/describes_itself'
require 'cucumber/core/ast/location'
require 'cucumber/core/ast/names'

lib/cucumber/core/ast/scenario_outline.rb on lines 20..28

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

Refactorings

Further Reading

Similar code found in 1 other location

# frozen_string_literal: true
require 'cucumber/core/ast/names'
require 'cucumber/core/ast/location'
require 'cucumber/core/ast/describes_itself'

lib/cucumber/core/ast/examples_table.rb on lines 15..23

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

Refactorings

Further Reading

Complex method in #enforce

          def enforce(test_cases)
            limit_breaches = limit_list.reduce([]) do |breaches, (tag_name, limit)|
              tag_count = test_cases.with_tag_name(tag_name).count
              if tag_count > limit
                tag_locations = test_cases.with_tag_name(tag_name).map(&:location)

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More