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 +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +11 -0
- data/lib/slimcop/cli.rb +1 -1
- data/lib/slimcop/path_finder.rb +20 -0
- data/lib/slimcop/ruby_offense_collector.rb +3 -2
- data/lib/slimcop/version.rb +1 -1
- data/lib/slimcop.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ab6599d37901d9e9929043564f7f33d4146f73f0cd7074e35f4d7270132593a
|
4
|
+
data.tar.gz: 6ffe356cf877e21bd58b96372c32f5b3c013ac411a90b94d883688f8ed324923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6571cd6e9631d02cb9bc5ee50c565e59f4bcfd0bea78fa9a1eb77ca0fdd4804851f5edf0b65b84b7e643fcbf844c117e33daf3c5d66992b998839f2f9438ef0b
|
7
|
+
data.tar.gz: 56ca6a6482bbffd3d1c7c3204a3bd1370d60aa18fce6535439c71ebbb3ada51a248a16d0d272ecb9cd9a0291dcb011c3996f3e0c26b03089b7c55fd06c30d179
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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
@@ -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
|
19
|
+
# @return [Array<RuboCop::Cop::Offense>]
|
20
20
|
def call
|
21
|
-
|
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
|
data/lib/slimcop/version.rb
CHANGED
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.
|
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-
|
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
|