fasterer 0.4.2 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1febf30dbcdf9c5b961a85811548a95f9fb1e4bb
4
- data.tar.gz: 7338f2684178241b12cb2d95cd06c4df07b263dc
3
+ metadata.gz: dad76ac74cc33d9e1f82e23005cef6f1bd60532e
4
+ data.tar.gz: ff12c05326d55e9e10b4c07f09bc9206e4994a11
5
5
  SHA512:
6
- metadata.gz: ee35ae5bd949ccc8bd03143cd012aa7238ed3721d4cd2d4a74e15f7f266af7e1f537c360d153f352627d1fa661af63fdcb92507fdf15bafe048a419203e895a7
7
- data.tar.gz: ba4cec762866c5f61b0a21118b82ff7aa3102acb6d84be2fdebfaf6342f669e5383328d29d15bdd555827075d082574f642fc3626d5a71395c5e3aa1f926d671
6
+ metadata.gz: c54c879d1264f00f6a783ddf42f0bd973c2fac6bfd7cea52857659215ea0fc7cd5f7937e683a6e8ef8f9bb3e99ae81b75d081d3c2a3c4fed588ce5a6f997e0ae
7
+ data.tar.gz: 5e0c03c6cbb14319cd8c3e1f1971cbe94962c3e97e5d2b522f639c875d424f9f602586d05bfa89537bcc02c359fd62690277b51021dffede35841244fa9dc1b5
@@ -15,7 +15,6 @@ speedups:
15
15
  block_vs_symbol_to_proc: true
16
16
  proc_call_vs_yield: true
17
17
  gsub_vs_tr: true
18
- select_last_vs_reverse_detect: true
19
18
  getter_vs_attr_reader: true
20
19
  setter_vs_attr_writer: true
21
20
 
@@ -1,7 +1,5 @@
1
1
  language: ruby
2
2
  before_install:
3
- # Travis bundler versions are quite out of date and can cause install errors
4
- # see: https://github.com/rubygems/rubygems/issues/1419
5
3
  - gem update bundler
6
4
  rvm:
7
5
  - 1.9.3
@@ -15,3 +13,12 @@ rvm:
15
13
  env:
16
14
  global:
17
15
  secure: MBTxmpWCjrsNKPlOoFwJUMHze3GPMz8YCXQFQG3zJBh3WGNQnz4z91ra/1P/DClyVCxHGSFCOswxCNe4kJ2zAnPyQLqGSinXy9uDpqZQUEdaRoQbPnh4/bguZNSJ429gtTpMdDSNOgQ+Hra2EFnWwHA+rLF6ImksMsu3XGKGxGE=
16
+ - CC_TEST_REPORTER_ID=86c5edffe4c38e16cb1467e3220a4f3dfa0a0ac8fa6ee8fddd62e200245f4b77
17
+ before_script:
18
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
19
+ - chmod +x ./cc-test-reporter
20
+ - ./cc-test-reporter before-build
21
+ script:
22
+ - bundle exec rspec
23
+ after_script:
24
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ - New style of outputting offenses: `spec/support/output/sample_code.rb:1 For loop is slower than using each.`
6
+
3
7
  ## 0.4.1
4
8
  - Upgrade ruby parser version to 3.11.0 (to stop warnings)
5
9
 
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
  [![Code Climate](https://codeclimate.com/github/DamirSvrtan/fasterer/badges/gpa.svg)](https://codeclimate.com/github/DamirSvrtan/fasterer)
3
3
  [![Gem Version](https://badge.fury.io/rb/fasterer.svg)](http://badge.fury.io/rb/fasterer)
4
4
  [![Test Coverage](https://codeclimate.com/github/DamirSvrtan/fasterer/badges/coverage.svg)](https://codeclimate.com/github/DamirSvrtan/fasterer/coverage)
5
- [![Dependency Status](https://gemnasium.com/DamirSvrtan/fasterer.svg)](https://gemnasium.com/DamirSvrtan/fasterer)
6
5
 
7
6
  # Fasterer
8
7
 
@@ -80,14 +80,14 @@ module Fasterer
80
80
  end
81
81
 
82
82
  def output(analyzer)
83
- puts analyzer.file_path.colorize(:red)
84
-
85
83
  offenses_grouped_by_type(analyzer).each do |error_group_name, error_occurences|
86
- puts "#{Fasterer::Offense::EXPLANATIONS[error_group_name]}."\
87
- " Occurred at lines: #{error_occurences.map(&:line_number).join(', ')}."
84
+ error_occurences.map(&:line_number).each do |line|
85
+ file_and_line = "#{analyzer.file_path}:#{line}"
86
+ print "#{file_and_line.colorize(:red)} #{Fasterer::Offense::EXPLANATIONS[error_group_name]}.\n"
87
+ end
88
88
  end
89
89
 
90
- puts
90
+ print "\n"
91
91
  end
92
92
 
93
93
  def offenses_grouped_by_type(analyzer)
@@ -1,3 +1,3 @@
1
1
  module Fasterer
2
- VERSION = '0.4.2'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -334,4 +334,24 @@ describe Fasterer::FileTraverser do
334
334
  .to match_array(['user.rb - RubyParser::SyntaxError - unterminated string meets end of file. near line 1: ""'])
335
335
  end
336
336
  end
337
+
338
+ describe 'output' do
339
+ let(:test_file_path) { RSpec.root.join('support', 'output', 'sample_code.rb') }
340
+ let(:analyzer) { Fasterer::Analyzer.new(test_file_path) }
341
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
342
+
343
+ before do
344
+ analyzer.scan
345
+ end
346
+
347
+ context "when print offenses" do
348
+ let(:explanation) { Fasterer::Offense::EXPLANATIONS[:for_loop_vs_each] }
349
+
350
+ it 'should print offense' do
351
+ match = "\e[0;31;49m#{test_file_path}:1\e[0m #{explanation}.\n\n"
352
+
353
+ expect { file_traverser.send(:output, analyzer) }.to output(match).to_stdout
354
+ end
355
+ end
356
+ end
337
357
  end
@@ -0,0 +1,3 @@
1
+ for number in [*1..100] do
2
+ number
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damir Svrtan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -220,6 +220,7 @@ files:
220
220
  - spec/support/method_definition/simple_method.rb
221
221
  - spec/support/method_definition/simple_method_omitted_parenthesis.rb
222
222
  - spec/support/method_definition/simple_method_with_argument.rb
223
+ - spec/support/output/sample_code.rb
223
224
  - spec/support/rescue_call/plain_rescue.rb
224
225
  - spec/support/rescue_call/rescue_with_class.rb
225
226
  - spec/support/rescue_call/rescue_with_class_and_variable.rb
@@ -325,6 +326,7 @@ test_files:
325
326
  - spec/support/method_definition/simple_method.rb
326
327
  - spec/support/method_definition/simple_method_omitted_parenthesis.rb
327
328
  - spec/support/method_definition/simple_method_with_argument.rb
329
+ - spec/support/output/sample_code.rb
328
330
  - spec/support/rescue_call/plain_rescue.rb
329
331
  - spec/support/rescue_call/rescue_with_class.rb
330
332
  - spec/support/rescue_call/rescue_with_class_and_variable.rb