slimcop 0.7.1 → 0.10.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 +33 -0
- data/Gemfile.lock +7 -3
- data/README.md +1 -1
- data/exe/slimcop +1 -0
- data/lib/slimcop/cli.rb +7 -7
- data/lib/slimcop/path_finder.rb +16 -1
- data/lib/slimcop/rubo_cop_config_generator.rb +16 -2
- data/lib/slimcop/version.rb +1 -1
- data/slimcop.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e411169bcf03ec8058dab2f6c316188b78cfda2ee5b10839f2bc89e0ffbcb7
|
4
|
+
data.tar.gz: 3081e815ee3f7ce7a518ab6a7b384042d4d96eda53bb8c5c776f3cbe21cd90e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adcd201a0fb01c9b40ec857f341bedec643648b463313433558bbc26564b2dc50742d771f68e40d8b9a4a829785e4e49cbbcda2d2ca147b94e8e61a9f5d3f183
|
7
|
+
data.tar.gz: 484b00bcf0e97e8980216cb70b0cd4badf5075eaf542f59657ceac2aa8de598c0059a58091210ee69c34bc09fdbe6df9ffc5d666169ccfa3da24a7a81bd10d44
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,39 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.10.0 - 2022-01-06
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Use .slimcop.yml as its 1st default config file.
|
10
|
+
|
11
|
+
## 0.9.1 - 2022-01-04
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Fix $LOAD_PATH at ./exe/slimcop.
|
16
|
+
|
17
|
+
## 0.9.0 - 2022-01-02
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
|
21
|
+
- Require slimi >= 0.5.1 to extract Ruby code from Ruby attribute.
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
|
25
|
+
- Fix -v and --version option.
|
26
|
+
|
27
|
+
## 0.8.0 - 2021-12-29
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
|
31
|
+
- Use .rubocop.yml by default.
|
32
|
+
- Use "**/*.slim" by default.
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- Fix bug that --no-color was not working.
|
37
|
+
|
5
38
|
## 0.7.1 - 2021-12-29
|
6
39
|
|
7
40
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slimcop (0.
|
4
|
+
slimcop (0.10.0)
|
5
5
|
rainbow
|
6
6
|
rubocop (>= 0.87)
|
7
|
-
slimi (>= 0.
|
7
|
+
slimi (>= 0.5.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -45,9 +45,13 @@ GEM
|
|
45
45
|
rubocop-rspec (2.6.0)
|
46
46
|
rubocop (~> 1.19)
|
47
47
|
ruby-progressbar (1.11.0)
|
48
|
-
slimi (0.
|
48
|
+
slimi (0.7.0)
|
49
49
|
temple
|
50
|
+
thor
|
51
|
+
tilt
|
50
52
|
temple (0.8.2)
|
53
|
+
thor (1.2.1)
|
54
|
+
tilt (2.0.10)
|
51
55
|
unicode-display_width (2.1.0)
|
52
56
|
|
53
57
|
PLATFORMS
|
data/README.md
CHANGED
data/exe/slimcop
CHANGED
data/lib/slimcop/cli.rb
CHANGED
@@ -7,18 +7,17 @@ module Slimcop
|
|
7
7
|
class Cli
|
8
8
|
def initialize(argv)
|
9
9
|
@argv = argv.dup
|
10
|
-
@formatter = ::RuboCop::Formatter::ProgressFormatter.new($stdout)
|
11
10
|
end
|
12
11
|
|
13
12
|
def call
|
14
13
|
options = parse!
|
15
|
-
|
14
|
+
formatter = ::RuboCop::Formatter::ProgressFormatter.new($stdout, color: options[:color])
|
16
15
|
rubocop_config = RuboCopConfigGenerator.new(additional_config_file_path: options[:additional_config_file_path]).call
|
17
16
|
file_paths = PathFinder.new(patterns: @argv).call
|
18
17
|
|
19
|
-
|
18
|
+
formatter.started(file_paths)
|
20
19
|
offenses = file_paths.flat_map do |file_path|
|
21
|
-
|
20
|
+
formatter.file_started(file_path, {})
|
22
21
|
source = ::File.read(file_path)
|
23
22
|
offenses_ = investigate(
|
24
23
|
auto_correct: options[:auto_correct],
|
@@ -33,10 +32,10 @@ module Slimcop
|
|
33
32
|
source: source
|
34
33
|
)
|
35
34
|
end
|
36
|
-
|
35
|
+
formatter.file_finished(file_path, offenses_)
|
37
36
|
offenses_
|
38
37
|
end
|
39
|
-
|
38
|
+
formatter.finished(file_paths)
|
40
39
|
exit(offenses.empty? ? 0 : 1)
|
41
40
|
end
|
42
41
|
|
@@ -73,10 +72,11 @@ module Slimcop
|
|
73
72
|
options = {}
|
74
73
|
parser = ::OptionParser.new
|
75
74
|
parser.banner = 'Usage: slimcop [options] [file1, file2, ...]'
|
75
|
+
parser.version = VERSION
|
76
76
|
parser.on('-a', '--auto-correct', 'Auto-correct offenses.') do
|
77
77
|
options[:auto_correct] = true
|
78
78
|
end
|
79
|
-
parser.on('-c', '--config=', 'Specify configuration file.') do |file_path|
|
79
|
+
parser.on('-c', '--config=', 'Specify configuration file. (default: .slimcop.yml or .rubocop.yml)') do |file_path|
|
80
80
|
options[:additional_config_file_path] = file_path
|
81
81
|
end
|
82
82
|
parser.on('--[no-]color', 'Force color output on or off.') do |value|
|
data/lib/slimcop/path_finder.rb
CHANGED
@@ -5,6 +5,10 @@ require 'pathname'
|
|
5
5
|
module Slimcop
|
6
6
|
# Collect file paths from given path patterns.
|
7
7
|
class PathFinder
|
8
|
+
DEFAULT_PATH_PATTERNS = %w[
|
9
|
+
**/*.slim
|
10
|
+
].freeze
|
11
|
+
|
8
12
|
# @param [Array<String>] patterns Patterns normally given as CLI arguments (e.g. `["app/views/**/*.html.slim"]`).
|
9
13
|
def initialize(patterns:)
|
10
14
|
@patterns = patterns
|
@@ -12,9 +16,20 @@ module Slimcop
|
|
12
16
|
|
13
17
|
# @return [Array<String>]
|
14
18
|
def call
|
15
|
-
|
19
|
+
patterns.flat_map do |pattern|
|
16
20
|
::Pathname.glob(pattern).select(&:file?).map(&:to_s)
|
17
21
|
end.uniq.sort
|
18
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# @return [Array<String>]
|
27
|
+
def patterns
|
28
|
+
if @patterns.empty?
|
29
|
+
DEFAULT_PATH_PATTERNS
|
30
|
+
else
|
31
|
+
@patterns
|
32
|
+
end
|
33
|
+
end
|
19
34
|
end
|
20
35
|
end
|
@@ -4,6 +4,9 @@ require 'rubocop'
|
|
4
4
|
|
5
5
|
module Slimcop
|
6
6
|
class RuboCopConfigGenerator
|
7
|
+
DEFAULT_ADDITIONAL_CONFIG_PATH1 = '.slimcop.yml'
|
8
|
+
DEFAULT_ADDITIONAL_CONFIG_PATH2 = '.rubocop.yml'
|
9
|
+
|
7
10
|
# @param [String] additional_config_file_path
|
8
11
|
def initialize(additional_config_file_path: nil)
|
9
12
|
@additional_config_file_path = additional_config_file_path
|
@@ -29,13 +32,24 @@ module Slimcop
|
|
29
32
|
# @return [Hash]
|
30
33
|
def merged_config_hash
|
31
34
|
result = slimcop_default_config
|
32
|
-
result = ::RuboCop::ConfigLoader.merge(result, additional_config) if
|
35
|
+
result = ::RuboCop::ConfigLoader.merge(result, additional_config) if additional_config
|
33
36
|
result
|
34
37
|
end
|
35
38
|
|
36
39
|
# @return [RuboCop::Config, nil]
|
37
40
|
def additional_config
|
38
|
-
|
41
|
+
if instance_variable_defined?(:@additional_config)
|
42
|
+
@additional_config
|
43
|
+
else
|
44
|
+
@additional_config = \
|
45
|
+
if @additional_config_file_path
|
46
|
+
::RuboCop::ConfigLoader.load_file(@additional_config_file_path)
|
47
|
+
elsif ::File.exist?(DEFAULT_ADDITIONAL_CONFIG_PATH1)
|
48
|
+
::RuboCop::ConfigLoader.load_file(DEFAULT_ADDITIONAL_CONFIG_PATH1)
|
49
|
+
elsif ::File.exist?(DEFAULT_ADDITIONAL_CONFIG_PATH2)
|
50
|
+
::RuboCop::ConfigLoader.load_file(DEFAULT_ADDITIONAL_CONFIG_PATH2)
|
51
|
+
end
|
52
|
+
end
|
39
53
|
end
|
40
54
|
|
41
55
|
# @return [RuboCop::Config]
|
data/lib/slimcop/version.rb
CHANGED
data/slimcop.gemspec
CHANGED
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.10.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:
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.5.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.5.1
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- r7kamura@gmail.com
|