warder 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -1
- data/bin/warder +6 -1
- data/features/checks_for_vulnerable_gems.feature +22 -0
- data/features/detects_code_complexity.feature +2 -3
- data/features/detects_code_duplication.feature +2 -2
- data/features/detects_code_smells.feature +2 -2
- data/features/detects_magick_numbers.feature +2 -2
- data/features/step_definitions/checks_for_vulnerable_gems_steps.rb +13 -0
- data/features/step_definitions/detects_code_complexity_steps.rb +7 -8
- data/features/step_definitions/detects_code_duplication_steps.rb +6 -7
- data/features/step_definitions/detects_code_smells_steps.rb +6 -7
- data/features/step_definitions/detects_magick_numbers_steps.rb +6 -7
- data/features/step_definitions/run_steps.rb +10 -0
- data/features/step_definitions/validates_style_guide_steps.rb +6 -7
- data/features/support/env.rb +1 -1
- data/features/validates_style_guide.feature +2 -2
- data/lib/warder.rb +1 -0
- data/lib/warder/bundle_audit_runner.rb +18 -0
- data/lib/warder/cli.rb +11 -2
- data/lib/warder/code_complexity_runner.rb +5 -7
- data/lib/warder/code_duplication_runner.rb +4 -12
- data/lib/warder/code_smells_runner.rb +2 -15
- data/lib/warder/magick_numbers_runner.rb +2 -8
- data/lib/warder/runner.rb +22 -8
- data/lib/warder/style_guide_runner.rb +2 -15
- data/lib/warder/version.rb +1 -1
- data/spec/fixtures/invalid_Gemfile +3 -0
- data/spec/fixtures/invalid_Gemfile.lock +14 -0
- data/spec/fixtures/valid_Gemfile +1 -0
- data/spec/fixtures/valid_Gemfile.lock +8 -0
- data/warder.gemspec +3 -0
- metadata +29 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7afe9d3043a0b79203eae14a874da4b7e7476b7f
         | 
| 4 | 
            +
              data.tar.gz: 77b48c7afb507db85255b71e0e8630db14e45a4b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b76bcd34640d62415548719b48c4d7ba13608cccf4382ec08992912ae53b904ac308ae9d2d208b9667918e50bd5fed0cd93356d201fdebdc5bd6f8296ec6324e
         | 
| 7 | 
            +
              data.tar.gz: c56a8c2cd0659cb171d6372f873ffedf6bac5cc7c68e4212c95ab936f4a6cbad7328cff1b41fc53a9251b810ac0ccecc6b35558c41f28e384dbcbb8cc4ae741d
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -6,4 +6,9 @@ gemfile: | |
| 6 6 | 
             
              - Gemfile
         | 
| 7 7 | 
             
            script:
         | 
| 8 8 | 
             
              - bundle exec rake
         | 
| 9 | 
            -
              - bundle exec warder --style-guide  | 
| 9 | 
            +
              - bundle exec warder --style-guide Gemfile Rakefile warder.gemspec bin/ lib/ features/
         | 
| 10 | 
            +
              - bundle exec warder --magick-numbers Gemfile Rakefile warder.gemspec bin/ lib/ features/
         | 
| 11 | 
            +
              - bundle exec warder --code-complexity Gemfile Rakefile warder.gemspec bin/ lib/ features/
         | 
| 12 | 
            +
              - bundle exec warder --code-smells Gemfile Rakefile warder.gemspec bin/ lib/ features/
         | 
| 13 | 
            +
              - bundle exec warder --code-duplication Gemfile Rakefile bin/ lib/ features/
         | 
| 14 | 
            +
              - bundle exec warder --bundle-audit
         | 
    
        data/bin/warder
    CHANGED
    
    | @@ -34,12 +34,17 @@ OptionParser.new do |opts| | |
| 34 34 | 
             
                options[:code_complexity] = value
         | 
| 35 35 | 
             
              end
         | 
| 36 36 |  | 
| 37 | 
            +
              desc = 'Run bundle freshness validation'
         | 
| 38 | 
            +
              opts.on('-b', '--[no-]bundle-audit', desc) do |value|
         | 
| 39 | 
            +
                options[:bundle_audit] = value
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 37 42 | 
             
              opts.on('-v', '--version', 'Show version') do |value|
         | 
| 38 43 | 
             
                puts Warder::VERSION
         | 
| 39 44 | 
             
                exit 0
         | 
| 40 45 | 
             
              end
         | 
| 41 46 | 
             
            end.parse!
         | 
| 42 47 |  | 
| 43 | 
            -
            options[:files] = ARGV.join(' ')
         | 
| 48 | 
            +
            options[:files] = ARGV.empty? ? '.' : ARGV.join(' ')
         | 
| 44 49 |  | 
| 45 50 | 
             
            Warder::CLI.new(options).perform
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Feature: checks for vulnerable gems
         | 
| 2 | 
            +
              In order to find vulnerable gems
         | 
| 3 | 
            +
              As a ruby developer
         | 
| 4 | 
            +
              I want to run warder with --bundle-audit option
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              Scenario: run warder with enabled bundle audit option
         | 
| 7 | 
            +
                Given I have valid gemfile in directory
         | 
| 8 | 
            +
                When I run `warder --bundle-audit`
         | 
| 9 | 
            +
                Then warder detects gem freshness issues
         | 
| 10 | 
            +
                Then the exit status should be 0
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              Scenario: run warder with enabled bundle audit option on invalid file
         | 
| 13 | 
            +
                Given I have invalid gemfile in directory
         | 
| 14 | 
            +
                When I run `warder --bundle-audit`
         | 
| 15 | 
            +
                Then warder detects gem freshness issues
         | 
| 16 | 
            +
                Then the exit status should be 1
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              Scenario: run warder with disabled bundle audit option on invalid file
         | 
| 19 | 
            +
                Given I have invalid gemfile in directory
         | 
| 20 | 
            +
                When I run `warder --no-bundle-audit`
         | 
| 21 | 
            +
                Then warder does nothing
         | 
| 22 | 
            +
                Then the exit status should be 0
         | 
| @@ -6,13 +6,13 @@ Feature: detects code complexity | |
| 6 6 | 
             
              Scenario: run warder with enabled code complexity option
         | 
| 7 7 | 
             
                Given I have valid file in directory
         | 
| 8 8 | 
             
                When I run `warder --code-complexity`
         | 
| 9 | 
            -
                Then warder detects code complexity
         | 
| 9 | 
            +
                Then warder detects code complexity issues
         | 
| 10 10 | 
             
                Then the exit status should be 0
         | 
| 11 11 |  | 
| 12 12 | 
             
              Scenario: run warder with enabled code complexity option on invalid file
         | 
| 13 13 | 
             
                Given I have invalid_code_complexity file in directory
         | 
| 14 14 | 
             
                When I run `warder --code-complexity`
         | 
| 15 | 
            -
                Then warder detects code complexity
         | 
| 15 | 
            +
                Then warder detects code complexity issues
         | 
| 16 16 | 
             
                Then the exit status should be 1
         | 
| 17 17 |  | 
| 18 18 | 
             
              Scenario: run warder with enabled code complexity option on valid file only
         | 
| @@ -27,4 +27,3 @@ Feature: detects code complexity | |
| 27 27 | 
             
                When I run `warder --no-code-complexity`
         | 
| 28 28 | 
             
                Then warder does nothing
         | 
| 29 29 | 
             
                Then the exit status should be 0
         | 
| 30 | 
            -
             | 
| @@ -6,13 +6,13 @@ Feature: detects code duplication | |
| 6 6 | 
             
              Scenario: run warder with enabled code duplication option
         | 
| 7 7 | 
             
                Given I have valid file in directory
         | 
| 8 8 | 
             
                When I run `warder --code-duplication`
         | 
| 9 | 
            -
                Then warder detects code duplication
         | 
| 9 | 
            +
                Then warder detects code duplication issues
         | 
| 10 10 | 
             
                Then the exit status should be 0
         | 
| 11 11 |  | 
| 12 12 | 
             
              Scenario: run warder with enabled code duplication option on invalid file
         | 
| 13 13 | 
             
                Given I have invalid_code_duplication file in directory
         | 
| 14 14 | 
             
                When I run `warder --code-duplication`
         | 
| 15 | 
            -
                Then warder detects code duplication
         | 
| 15 | 
            +
                Then warder detects code duplication issues
         | 
| 16 16 | 
             
                Then the exit status should be 1
         | 
| 17 17 |  | 
| 18 18 | 
             
              Scenario: run warder with enabled code duplication option on valid file only
         | 
| @@ -6,13 +6,13 @@ Feature: detects code smells | |
| 6 6 | 
             
              Scenario: run warder with enabled code smells option
         | 
| 7 7 | 
             
                Given I have valid file in directory
         | 
| 8 8 | 
             
                When I run `warder --code-smells`
         | 
| 9 | 
            -
                Then warder detects code smells
         | 
| 9 | 
            +
                Then warder detects code smells issues
         | 
| 10 10 | 
             
                Then the exit status should be 0
         | 
| 11 11 |  | 
| 12 12 | 
             
              Scenario: run warder with enabled code smells option on invalid file
         | 
| 13 13 | 
             
                Given I have invalid_code_smells file in directory
         | 
| 14 14 | 
             
                When I run `warder --code-smells`
         | 
| 15 | 
            -
                Then warder detects code smells
         | 
| 15 | 
            +
                Then warder detects code smells issues
         | 
| 16 16 | 
             
                Then the exit status should be 1
         | 
| 17 17 |  | 
| 18 18 | 
             
              Scenario: run warder with enabled code smells option on valid file only
         | 
| @@ -6,13 +6,13 @@ Feature: detects magick numbers | |
| 6 6 | 
             
              Scenario: run warder with enabled magick numbers option
         | 
| 7 7 | 
             
                Given I have valid file in directory
         | 
| 8 8 | 
             
                When I run `warder --magick-numbers`
         | 
| 9 | 
            -
                Then warder detects magick numbers
         | 
| 9 | 
            +
                Then warder detects magick numbers issues
         | 
| 10 10 | 
             
                Then the exit status should be 0
         | 
| 11 11 |  | 
| 12 12 | 
             
              Scenario: run warder with enabled magick numbers option on invalid file
         | 
| 13 13 | 
             
                Given I have invalid_magick_numbers file in directory
         | 
| 14 14 | 
             
                When I run `warder --magick-numbers`
         | 
| 15 | 
            -
                Then warder detects magick numbers
         | 
| 15 | 
            +
                Then warder detects magick numbers issues
         | 
| 16 16 | 
             
                Then the exit status should be 1
         | 
| 17 17 |  | 
| 18 18 | 
             
              Scenario: run warder with enabled magick numbers option on valid file only
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            def executing_gem_freshness
         | 
| 2 | 
            +
              "executing 'bundle-audit update; (cd . && bundle-audit check)'"
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def gem_freshness_output
         | 
| 6 | 
            +
              `cd tmp/aruba/ && bundle-audit check`
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Given(/^I have ((in)?valid) gemfile in directory$/) do |state, _|
         | 
| 10 | 
            +
              @filename = "#{state}_Gemfile.lock"
         | 
| 11 | 
            +
              FileUtils.ln_s "../../spec/fixtures/#{@filename}", 'tmp/aruba/Gemfile.lock'
         | 
| 12 | 
            +
              expect(`ls tmp/aruba`).to match('Gemfile.lock')
         | 
| 13 | 
            +
            end
         | 
| @@ -1,11 +1,10 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 1 | 
            +
            def executing_code_complexity
         | 
| 2 | 
            +
              "executing 'flog -a -c -g -m .'"
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def code_complexity_output
         | 
| 6 | 
            +
              `cd spec/fixtures/ && flog -a -c -g -m ./#{@filename}`
         | 
| 6 7 | 
             
                .split("\n")
         | 
| 7 8 | 
             
                .reject { |line| line.match(/total|average/) }
         | 
| 8 | 
            -
                . | 
| 9 | 
            -
                step "the output should contain \"#{string}\""
         | 
| 10 | 
            -
              end
         | 
| 9 | 
            +
                .join("\n")
         | 
| 11 10 | 
             
            end
         | 
| @@ -1,8 +1,7 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
              end
         | 
| 1 | 
            +
            def executing_code_duplication
         | 
| 2 | 
            +
              "executing 'flay -d -m 15 .'"
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def code_duplication_output
         | 
| 6 | 
            +
              `cd spec/fixtures/ && flay -d ./#{@filename}`
         | 
| 8 7 | 
             
            end
         | 
| @@ -1,8 +1,7 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
              end
         | 
| 1 | 
            +
            def executing_code_smells
         | 
| 2 | 
            +
              "executing 'reek .'"
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def code_smells_output
         | 
| 6 | 
            +
              `cd spec/fixtures/ && reek #{@filename}`
         | 
| 8 7 | 
             
            end
         | 
| @@ -1,8 +1,7 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
              end
         | 
| 1 | 
            +
            def executing_magick_numbers
         | 
| 2 | 
            +
              "executing 'mago .'"
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def magick_numbers_output
         | 
| 6 | 
            +
              `cd spec/fixtures/ && mago #{@filename}`
         | 
| 8 7 | 
             
            end
         | 
| @@ -15,3 +15,13 @@ end | |
| 15 15 | 
             
            Then(/^warder does nothing$/) do
         | 
| 16 16 | 
             
              step 'the output should match /.{0}/'
         | 
| 17 17 | 
             
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Then(/^warder detects (.+) issues$/) do |what|
         | 
| 20 | 
            +
              executing_output = send(:"executing_#{what.sub(' ', '_')}")
         | 
| 21 | 
            +
              step "the output should contain \"#{executing_output}\""
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              validation_output = send(:"#{what.sub(' ', '_')}_output")
         | 
| 24 | 
            +
              validation_output.split("\n").each do |string|
         | 
| 25 | 
            +
                step "the output should contain \"#{string}\""
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -1,8 +1,7 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
               | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
              end
         | 
| 1 | 
            +
            def executing_style_guide
         | 
| 2 | 
            +
              "executing 'rubocop .'"
         | 
| 3 | 
            +
            end
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            def style_guide_output
         | 
| 6 | 
            +
              `cd spec/fixtures/ && rubocop #{@filename}`
         | 
| 8 7 | 
             
            end
         | 
    
        data/features/support/env.rb
    CHANGED
    
    
| @@ -6,13 +6,13 @@ Feature: check style guide | |
| 6 6 | 
             
              Scenario: run warder with enabled style guide option
         | 
| 7 7 | 
             
                Given I have valid file in directory
         | 
| 8 8 | 
             
                When I run `warder --style-guide`
         | 
| 9 | 
            -
                Then warder  | 
| 9 | 
            +
                Then warder detects style guide issues
         | 
| 10 10 | 
             
                Then the exit status should be 0
         | 
| 11 11 |  | 
| 12 12 | 
             
              Scenario: run warder with enabled style guide option on invalid file
         | 
| 13 13 | 
             
                Given I have invalid_style_guide file in directory
         | 
| 14 14 | 
             
                When I run `warder --style-guide`
         | 
| 15 | 
            -
                Then warder  | 
| 15 | 
            +
                Then warder detects style guide issues
         | 
| 16 16 | 
             
                Then the exit status should be 1
         | 
| 17 17 |  | 
| 18 18 | 
             
              Scenario: run warder with enabled style guide option on valid file only
         | 
    
        data/lib/warder.rb
    CHANGED
    
    
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            module Warder
         | 
| 2 | 
            +
              # responsible for run bundle freshness validation
         | 
| 3 | 
            +
              class BundleAuditRunner < Runner
         | 
| 4 | 
            +
                COMMAND_NAME = 'bundle-audit'
         | 
| 5 | 
            +
                FAILURE_REGEXP = /Unpatched versions found!/
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                private
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def command_with_options
         | 
| 10 | 
            +
                  path = @options.files[0]
         | 
| 11 | 
            +
                  "#{COMMAND_NAME} update; (cd #{path} && #{COMMAND_NAME} check)"
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def failed?(line)
         | 
| 15 | 
            +
                  FAILURE_REGEXP.match(line)
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
    
        data/lib/warder/cli.rb
    CHANGED
    
    | @@ -2,7 +2,6 @@ module Warder | |
| 2 2 | 
             
              # responsible for executing warder tools
         | 
| 3 3 | 
             
              class CLI
         | 
| 4 4 | 
             
                def initialize(options)
         | 
| 5 | 
            -
                  options[:files] = '.' if options[:files].empty?
         | 
| 6 5 | 
             
                  @options = OpenStruct.new(options)
         | 
| 7 6 | 
             
                end
         | 
| 8 7 |  | 
| @@ -11,7 +10,8 @@ module Warder | |
| 11 10 | 
             
                         perform_magick_numbers_validation +
         | 
| 12 11 | 
             
                         perform_code_duplication_validation +
         | 
| 13 12 | 
             
                         perform_code_smells_validation +
         | 
| 14 | 
            -
                         perform_code_complexity_validation
         | 
| 13 | 
            +
                         perform_code_complexity_validation +
         | 
| 14 | 
            +
                         perform_bundle_freshness_validation
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                private
         | 
| @@ -60,5 +60,14 @@ module Warder | |
| 60 60 | 
             
                    0
         | 
| 61 61 | 
             
                  end
         | 
| 62 62 | 
             
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                def perform_bundle_freshness_validation
         | 
| 65 | 
            +
                  if @options.bundle_audit
         | 
| 66 | 
            +
                    runner = BundleAuditRunner.new(@options)
         | 
| 67 | 
            +
                    runner.perform
         | 
| 68 | 
            +
                  else
         | 
| 69 | 
            +
                    0
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
                end
         | 
| 63 72 | 
             
              end
         | 
| 64 73 | 
             
            end
         | 
| @@ -2,15 +2,13 @@ module Warder | |
| 2 2 | 
             
              # responsible for run code complexity validation
         | 
| 3 3 | 
             
              class CodeComplexityRunner < Runner
         | 
| 4 4 | 
             
                FLOG_SCORE = SCORE
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                 | 
| 7 | 
            -
                  @options = options
         | 
| 8 | 
            -
                end
         | 
| 5 | 
            +
                COMMAND_NAME = 'flog'
         | 
| 6 | 
            +
                TOTAL_REGEXP = /^\s+\d+.\d+\:.*(total|average)$/
         | 
| 9 7 |  | 
| 10 8 | 
             
                private
         | 
| 11 9 |  | 
| 12 | 
            -
                def  | 
| 13 | 
            -
                  " | 
| 10 | 
            +
                def command_with_options
         | 
| 11 | 
            +
                  "#{COMMAND_NAME} -a -c -g -m #{@options.files}"
         | 
| 14 12 | 
             
                end
         | 
| 15 13 |  | 
| 16 14 | 
             
                def failed?(line)
         | 
| @@ -24,7 +22,7 @@ module Warder | |
| 24 22 | 
             
                end
         | 
| 25 23 |  | 
| 26 24 | 
             
                def total?(line)
         | 
| 27 | 
            -
                   | 
| 25 | 
            +
                  TOTAL_REGEXP.match(line)
         | 
| 28 26 | 
             
                end
         | 
| 29 27 | 
             
              end
         | 
| 30 28 | 
             
            end
         | 
| @@ -2,21 +2,13 @@ module Warder | |
| 2 2 | 
             
              # responsible for run code duplication validation
         | 
| 3 3 | 
             
              class CodeDuplicationRunner < Runner
         | 
| 4 4 | 
             
                FLAY_SCORE = SCORE / 2
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                 | 
| 7 | 
            -
                  @options = options
         | 
| 8 | 
            -
                end
         | 
| 5 | 
            +
                COMMAND_NAME = 'flay'
         | 
| 6 | 
            +
                FAILURE_REGEXP = /Total score \(lower is better\) = (\d+)/
         | 
| 9 7 |  | 
| 10 8 | 
             
                private
         | 
| 11 9 |  | 
| 12 | 
            -
                def  | 
| 13 | 
            -
                  " | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                def failed?(line)
         | 
| 17 | 
            -
                  match = line.match(/Total score \(lower is better\) = (\d+)/)
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  match && match[1].to_i != 0
         | 
| 10 | 
            +
                def command_with_options
         | 
| 11 | 
            +
                  "#{COMMAND_NAME} -d -m #{FLAY_SCORE} #{@options.files}"
         | 
| 20 12 | 
             
                end
         | 
| 21 13 | 
             
              end
         | 
| 22 14 | 
             
            end
         | 
| @@ -1,20 +1,7 @@ | |
| 1 1 | 
             
            module Warder
         | 
| 2 2 | 
             
              # responsible for run code smells validation
         | 
| 3 3 | 
             
              class CodeSmellsRunner < Runner
         | 
| 4 | 
            -
                 | 
| 5 | 
            -
             | 
| 6 | 
            -
                end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                private
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                def command
         | 
| 11 | 
            -
                  "reek #{@options.files}"
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                def failed?(line)
         | 
| 15 | 
            -
                  match = line.match(/ -- (\d+) warnings?:/)
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  match && match[1].to_i != 0
         | 
| 18 | 
            -
                end
         | 
| 4 | 
            +
                COMMAND_NAME = 'reek'
         | 
| 5 | 
            +
                FAILURE_REGEXP = / -- (\d+) warnings?:/
         | 
| 19 6 | 
             
              end
         | 
| 20 7 | 
             
            end
         | 
| @@ -1,17 +1,11 @@ | |
| 1 1 | 
             
            module Warder
         | 
| 2 2 | 
             
              # responsible for run magick numbers validation
         | 
| 3 3 | 
             
              class MagickNumbersRunner < Runner
         | 
| 4 | 
            -
                 | 
| 5 | 
            -
                  @options = options
         | 
| 6 | 
            -
                end
         | 
| 4 | 
            +
                COMMAND_NAME = 'mago'
         | 
| 7 5 |  | 
| 8 6 | 
             
                private
         | 
| 9 7 |  | 
| 10 | 
            -
                def  | 
| 11 | 
            -
                  "mago #{@options.files}"
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                def failed?(line)
         | 
| 8 | 
            +
                def failed?(*)
         | 
| 15 9 | 
             
                  true
         | 
| 16 10 | 
             
                end
         | 
| 17 11 | 
             
              end
         | 
    
        data/lib/warder/runner.rb
    CHANGED
    
    | @@ -3,24 +3,38 @@ module Warder | |
| 3 3 | 
             
              class Runner
         | 
| 4 4 | 
             
                SCORE = 30
         | 
| 5 5 |  | 
| 6 | 
            +
                def initialize(options = {})
         | 
| 7 | 
            +
                  @options = options
         | 
| 8 | 
            +
                  @exit_code = 0
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 6 11 | 
             
                def perform
         | 
| 7 | 
            -
                   | 
| 8 | 
            -
                  code = 0
         | 
| 9 | 
            -
                  IO.popen(command).each do |line|
         | 
| 12 | 
            +
                  run_command do |line|
         | 
| 10 13 | 
             
                    print line if printable?(line)
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                    code = 1 if failed?(line)
         | 
| 14 | 
            +
                    @exit_code = 1 if failed?(line)
         | 
| 13 15 | 
             
                  end
         | 
| 14 | 
            -
                   | 
| 16 | 
            +
                  @exit_code
         | 
| 15 17 | 
             
                end
         | 
| 16 18 |  | 
| 17 19 | 
             
                private
         | 
| 18 20 |  | 
| 21 | 
            +
                def run_command
         | 
| 22 | 
            +
                  puts "executing '#{command_with_options}'\n"
         | 
| 23 | 
            +
                  IO.popen(command_with_options).each do |line|
         | 
| 24 | 
            +
                    yield(line)
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def command_with_options
         | 
| 29 | 
            +
                  "#{self.class::COMMAND_NAME} #{@options.files}"
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 19 32 | 
             
                def failed?(line)
         | 
| 20 | 
            -
                   | 
| 33 | 
            +
                  match = line.match(self.class::FAILURE_REGEXP)
         | 
| 34 | 
            +
                  match && match[1].to_i != 0
         | 
| 21 35 | 
             
                end
         | 
| 22 36 |  | 
| 23 | 
            -
                def printable?( | 
| 37 | 
            +
                def printable?(*)
         | 
| 24 38 | 
             
                  true
         | 
| 25 39 | 
             
                end
         | 
| 26 40 | 
             
              end
         | 
| @@ -1,20 +1,7 @@ | |
| 1 1 | 
             
            module Warder
         | 
| 2 2 | 
             
              # responsible for run style guide validation
         | 
| 3 3 | 
             
              class StyleGuideRunner < Runner
         | 
| 4 | 
            -
                 | 
| 5 | 
            -
             | 
| 6 | 
            -
                end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                private
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                def command
         | 
| 11 | 
            -
                  "rubocop #{@options.files}"
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                def failed?(line)
         | 
| 15 | 
            -
                  match = line.match(/(\d+|no) offence/)
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  match && match[1].to_i != 0
         | 
| 18 | 
            -
                end
         | 
| 4 | 
            +
                COMMAND_NAME = 'rubocop'
         | 
| 5 | 
            +
                FAILURE_REGEXP = /(\d+|no) offence/
         | 
| 19 6 | 
             
              end
         | 
| 20 7 | 
             
            end
         | 
    
        data/lib/warder/version.rb
    CHANGED
    
    
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            source 'https://rubygems.org'
         | 
    
        data/warder.gemspec
    CHANGED
    
    | @@ -24,7 +24,10 @@ Gem::Specification.new do |spec| | |
| 24 24 | 
             
              spec.add_dependency 'ruby2ruby'
         | 
| 25 25 | 
             
              spec.add_dependency 'flog'
         | 
| 26 26 | 
             
              spec.add_dependency 'mago'
         | 
| 27 | 
            +
              spec.add_dependency 'bundler-audit'
         | 
| 27 28 | 
             
              # spec.add_dependency 'sandi_meter'
         | 
| 29 | 
            +
              # spec.add_dependency 'brakeman'
         | 
| 30 | 
            +
              # spec.add_dependency 'rails_best_practices'
         | 
| 28 31 |  | 
| 29 32 | 
             
              spec.add_development_dependency 'bundler', '~> 1.3'
         | 
| 30 33 | 
             
              spec.add_development_dependency 'rake'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: warder
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Yura Tolstik
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-01- | 
| 11 | 
            +
            date: 2014-01-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rubocop
         | 
| @@ -94,6 +94,20 @@ dependencies: | |
| 94 94 | 
             
                - - ">="
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 96 | 
             
                    version: '0'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: bundler-audit
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :runtime
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 97 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 112 | 
             
              name: bundler
         | 
| 99 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -180,12 +194,14 @@ files: | |
| 180 194 | 
             
            - Rakefile
         | 
| 181 195 | 
             
            - bin/warder
         | 
| 182 196 | 
             
            - cucumber.yml
         | 
| 197 | 
            +
            - features/checks_for_vulnerable_gems.feature
         | 
| 183 198 | 
             
            - features/detects_code_complexity.feature
         | 
| 184 199 | 
             
            - features/detects_code_duplication.feature
         | 
| 185 200 | 
             
            - features/detects_code_smells.feature
         | 
| 186 201 | 
             
            - features/detects_magick_numbers.feature
         | 
| 187 202 | 
             
            - features/run.feature
         | 
| 188 203 | 
             
            - features/show_version.feature
         | 
| 204 | 
            +
            - features/step_definitions/checks_for_vulnerable_gems_steps.rb
         | 
| 189 205 | 
             
            - features/step_definitions/detects_code_complexity_steps.rb
         | 
| 190 206 | 
             
            - features/step_definitions/detects_code_duplication_steps.rb
         | 
| 191 207 | 
             
            - features/step_definitions/detects_code_smells_steps.rb
         | 
| @@ -196,6 +212,7 @@ files: | |
| 196 212 | 
             
            - features/support/env.rb
         | 
| 197 213 | 
             
            - features/validates_style_guide.feature
         | 
| 198 214 | 
             
            - lib/warder.rb
         | 
| 215 | 
            +
            - lib/warder/bundle_audit_runner.rb
         | 
| 199 216 | 
             
            - lib/warder/cli.rb
         | 
| 200 217 | 
             
            - lib/warder/code_complexity_runner.rb
         | 
| 201 218 | 
             
            - lib/warder/code_duplication_runner.rb
         | 
| @@ -204,6 +221,8 @@ files: | |
| 204 221 | 
             
            - lib/warder/runner.rb
         | 
| 205 222 | 
             
            - lib/warder/style_guide_runner.rb
         | 
| 206 223 | 
             
            - lib/warder/version.rb
         | 
| 224 | 
            +
            - spec/fixtures/invalid_Gemfile
         | 
| 225 | 
            +
            - spec/fixtures/invalid_Gemfile.lock
         | 
| 207 226 | 
             
            - spec/fixtures/invalid_code_complexity.rb
         | 
| 208 227 | 
             
            - spec/fixtures/invalid_code_duplication.rb
         | 
| 209 228 | 
             
            - spec/fixtures/invalid_code_smells.rb
         | 
| @@ -211,6 +230,8 @@ files: | |
| 211 230 | 
             
            - spec/fixtures/invalid_style_guide.rb
         | 
| 212 231 | 
             
            - spec/fixtures/strictly_invalid_style_guide.rb
         | 
| 213 232 | 
             
            - spec/fixtures/valid.rb
         | 
| 233 | 
            +
            - spec/fixtures/valid_Gemfile
         | 
| 234 | 
            +
            - spec/fixtures/valid_Gemfile.lock
         | 
| 214 235 | 
             
            - spec/spec_helper.rb
         | 
| 215 236 | 
             
            - warder.gemspec
         | 
| 216 237 | 
             
            homepage: https://github.com/yltsrc/warder
         | 
| @@ -238,12 +259,14 @@ signing_key: | |
| 238 259 | 
             
            specification_version: 4
         | 
| 239 260 | 
             
            summary: Warder of ruby code
         | 
| 240 261 | 
             
            test_files:
         | 
| 262 | 
            +
            - features/checks_for_vulnerable_gems.feature
         | 
| 241 263 | 
             
            - features/detects_code_complexity.feature
         | 
| 242 264 | 
             
            - features/detects_code_duplication.feature
         | 
| 243 265 | 
             
            - features/detects_code_smells.feature
         | 
| 244 266 | 
             
            - features/detects_magick_numbers.feature
         | 
| 245 267 | 
             
            - features/run.feature
         | 
| 246 268 | 
             
            - features/show_version.feature
         | 
| 269 | 
            +
            - features/step_definitions/checks_for_vulnerable_gems_steps.rb
         | 
| 247 270 | 
             
            - features/step_definitions/detects_code_complexity_steps.rb
         | 
| 248 271 | 
             
            - features/step_definitions/detects_code_duplication_steps.rb
         | 
| 249 272 | 
             
            - features/step_definitions/detects_code_smells_steps.rb
         | 
| @@ -253,6 +276,8 @@ test_files: | |
| 253 276 | 
             
            - features/step_definitions/validates_style_guide_steps.rb
         | 
| 254 277 | 
             
            - features/support/env.rb
         | 
| 255 278 | 
             
            - features/validates_style_guide.feature
         | 
| 279 | 
            +
            - spec/fixtures/invalid_Gemfile
         | 
| 280 | 
            +
            - spec/fixtures/invalid_Gemfile.lock
         | 
| 256 281 | 
             
            - spec/fixtures/invalid_code_complexity.rb
         | 
| 257 282 | 
             
            - spec/fixtures/invalid_code_duplication.rb
         | 
| 258 283 | 
             
            - spec/fixtures/invalid_code_smells.rb
         | 
| @@ -260,4 +285,6 @@ test_files: | |
| 260 285 | 
             
            - spec/fixtures/invalid_style_guide.rb
         | 
| 261 286 | 
             
            - spec/fixtures/strictly_invalid_style_guide.rb
         | 
| 262 287 | 
             
            - spec/fixtures/valid.rb
         | 
| 288 | 
            +
            - spec/fixtures/valid_Gemfile
         | 
| 289 | 
            +
            - spec/fixtures/valid_Gemfile.lock
         | 
| 263 290 | 
             
            - spec/spec_helper.rb
         |