Sha256: f3ea511935d0ddd9f86545ee54361a116859ecb830b8fc1e53b7660f1a833f3e

Contents?: true

Size: 657 Bytes

Versions: 9

Compression:

Stored size: 657 Bytes

Contents

module Chutney
  # service class to lint for avoid scripting
  class AvoidScripting < Linter  
    def lint
      scenarios do |feature, scenario|
        when_steps = filter_when_steps(scenario[:steps])
        whens = when_steps.count
        add_issue(I18n.t('linters.avoid_scripting', count: whens), feature, scenario, when_steps.last) if whens > 1
      end
    end
    
    def filter_when_steps(steps)
      steps
        .drop_while { |step| !when_word?(step[:keyword]) }
        .then { |s| s.reverse.drop_while { |step| !then_word?(step[:keyword]) }.reverse }
        .then { |s| s.reject { |step| then_word?(step[:keyword]) } }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chutney-2.2.1 lib/chutney/linter/avoid_scripting.rb
chutney-2.1.1 lib/chutney/linter/avoid_scripting.rb
chutney-2.1.0 lib/chutney/linter/avoid_scripting.rb
chutney-2.0.3.1 lib/chutney/linter/avoid_scripting.rb
chutney-2.0.3 lib/chutney/linter/avoid_scripting.rb
chutney-2.0.2 lib/chutney/linter/avoid_scripting.rb
chutney-2.0.1 lib/chutney/linter/avoid_scripting.rb
chutney-2.0.0 lib/chutney/linter/avoid_scripting.rb
chutney-2.0.0.rc1 lib/chutney/linter/avoid_scripting.rb