slimcop 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: e43c25d5b3588ae90dd33cff028ef9c42ada8905782d8ac97049324948e0e8f6
4
- data.tar.gz: b487022dc36d88c433ff0cf5b2666fe97e27a0e88b3def78fcbc51a2f33d753c
3
+ metadata.gz: 9ab6599d37901d9e9929043564f7f33d4146f73f0cd7074e35f4d7270132593a
4
+ data.tar.gz: 6ffe356cf877e21bd58b96372c32f5b3c013ac411a90b94d883688f8ed324923
5
5
  SHA512:
6
- metadata.gz: fba92c121be30436567f9cc30cb22570a8bc3f6316d8564681d9d124a2400296590fed6f0c11b7b3cb3ea16d3e48ebd3f53ba9719bc085bf76b731f1c7115e29
7
- data.tar.gz: df506c25b9b513589bf05391555b83228e976b000c4117e55d85b8e209ef613c25beef1b8e981a871e8c17382048d472a59dce3386cd1f034164ec81e528b547
6
+ metadata.gz: 6571cd6e9631d02cb9bc5ee50c565e59f4bcfd0bea78fa9a1eb77ca0fdd4804851f5edf0b65b84b7e643fcbf844c117e33daf3c5d66992b998839f2f9438ef0b
7
+ data.tar.gz: 56ca6a6482bbffd3d1c7c3204a3bd1370d60aa18fce6535439c71ebbb3ada51a248a16d0d272ecb9cd9a0291dcb011c3996f3e0c26b03089b7c55fd06c30d179
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.4.0 - 2021-12-26
6
+
7
+ ### Added
8
+
9
+ - Support glob pattern on arguments of executable.
10
+
11
+ ### Fixed
12
+
13
+ - Fix bug on parsing invalid syntax Ruby code.
14
+
5
15
  ## 0.3.0 - 2021-12-25
6
16
 
7
17
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slimcop (0.3.0)
4
+ slimcop (0.4.0)
5
5
  rainbow
6
6
  rubocop (>= 0.87)
7
7
  slimi (>= 0.4)
data/README.md CHANGED
@@ -35,3 +35,14 @@ Usage: slimcop [options] [file1, file2, ...]
35
35
  -a, --auto-correct Auto-correct offenses.
36
36
  --[no-]color Force color output on or off.
37
37
  ```
38
+
39
+ ### Example
40
+
41
+ ```console
42
+ $ slimcop spec/**/*.slim
43
+
44
+ Offenses:
45
+
46
+ spec/fixtures/dummy.slim:1:3 C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
47
+ spec/fixtures/dummy.slim:3:5 C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
48
+ ```
data/lib/slimcop/cli.rb CHANGED
@@ -12,7 +12,7 @@ module Slimcop
12
12
 
13
13
  def call
14
14
  options = parse!
15
- slim_file_paths = @argv
15
+ slim_file_paths = PathFinder.new(patterns: @argv).call
16
16
 
17
17
  Rainbow.enabled = options[:color] if options.key?(:color)
18
18
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ module Slimcop
6
+ # Collect file paths from given path patterns.
7
+ class PathFinder
8
+ # @param [Array<String>] patterns Patterns normally given as CLI arguments (e.g. `["app/views/**/*.html.slim"]`).
9
+ def initialize(patterns:)
10
+ @patterns = patterns
11
+ end
12
+
13
+ # @return [Array<String>]
14
+ def call
15
+ @patterns.flat_map do |pattern|
16
+ ::Pathname.glob(pattern).select(&:file?).map(&:to_s)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -16,9 +16,10 @@ module Slimcop
16
16
  @source = source
17
17
  end
18
18
 
19
- # @return [Array<RuboCop::Cop::Offense>, nil]
19
+ # @return [Array<RuboCop::Cop::Offense>]
20
20
  def call
21
- return unless rubocop_processed_source.valid_syntax?
21
+ # Skip if invalid syntax Ruby code is given. (e.g. "- if a?")
22
+ return [] unless rubocop_processed_source.valid_syntax?
22
23
 
23
24
  rubocop_team.investigate(rubocop_processed_source).offenses
24
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Slimcop
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/slimcop.rb CHANGED
@@ -7,6 +7,7 @@ module Slimcop
7
7
  autoload :Configuration, 'slimcop/configuration'
8
8
  autoload :Formatter, 'slimcop/formatter'
9
9
  autoload :Offense, 'slimcop/offense'
10
+ autoload :PathFinder, 'slimcop/path_finder'
10
11
  autoload :RubyExtractor, 'slimcop/ruby_extractor'
11
12
  autoload :RubyOffenseCollector, 'slimcop/ruby_offense_collector'
12
13
  autoload :SlimCorrector, 'slimcop/slim_corrector'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimcop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-24 00:00:00.000000000 Z
11
+ date: 2021-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -78,6 +78,7 @@ files:
78
78
  - lib/slimcop/configuration.rb
79
79
  - lib/slimcop/formatter.rb
80
80
  - lib/slimcop/offense.rb
81
+ - lib/slimcop/path_finder.rb
81
82
  - lib/slimcop/ruby_extractor.rb
82
83
  - lib/slimcop/ruby_offense_collector.rb
83
84
  - lib/slimcop/slim_corrector.rb