avm-eac_ruby_base1 0.44.0 → 0.45.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/lib/avm/eac_ruby_base1/file_formats/base.rb +2 -1
- data/lib/avm/eac_ruby_base1/rubocop/command/build.rb +41 -0
- data/lib/avm/eac_ruby_base1/rubocop/command.rb +80 -0
- data/lib/avm/eac_ruby_base1/rubocop/offense_set/file.rb +51 -0
- data/lib/avm/eac_ruby_base1/rubocop/offense_set/line_processor.rb +54 -0
- data/lib/avm/eac_ruby_base1/rubocop/offense_set/offense.rb +34 -0
- data/lib/avm/eac_ruby_base1/rubocop/offense_set.rb +28 -0
- data/lib/avm/eac_ruby_base1/rubocop/runner/configured.rb +31 -0
- data/lib/avm/eac_ruby_base1/rubocop/runner/envvar.rb +17 -0
- data/lib/avm/eac_ruby_base1/rubocop/runner/gemfile.rb +41 -0
- data/lib/avm/eac_ruby_base1/rubocop/runner.rb +56 -0
- data/lib/avm/eac_ruby_base1/runners/base/rubocop.rb +1 -1
- data/lib/avm/eac_ruby_base1/sources/base/rubocop.rb +11 -0
- data/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb +18 -37
- data/lib/avm/eac_ruby_base1/sources/base/update.rb +2 -1
- data/lib/avm/eac_ruby_base1/sources/update/changes/rubocop_format.rb +31 -0
- data/lib/avm/eac_ruby_base1/sources/update/changes/update_requirements.rb +1 -1
- data/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/locale/en.yml +2 -0
- data/locale/pt-BR.yml +2 -0
- metadata +14 -7
- data/lib/avm/eac_ruby_base1/rubocop/configured.rb +0 -29
- data/lib/avm/eac_ruby_base1/rubocop/envvar.rb +0 -15
- data/lib/avm/eac_ruby_base1/rubocop/gemfile.rb +0 -39
- data/lib/avm/eac_ruby_base1/rubocop.rb +0 -54
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5122f9094f7863d448524359ed524683672bace2aec4d3bdaf0a79f6fcfdf470
|
|
4
|
+
data.tar.gz: aaf9510c1a8b3f66c1fc1c42baeacc37fe105443a675a154fc8c5eb9db7e9493
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 416ecc929867bf45171ef12ee0b582d7f88deede7a7821622f6cc8a9f69e6cc920dfb3a5886f756eed45c5c683ee7caafcd06a4074e95e55c1e775539c7dd29f
|
|
7
|
+
data.tar.gz: bc4b114ed108e21efa07a76401d7700cf5376c2340f314c375a63362db2ef4bfeaabd2b8c4d4044ec2598c4453f10519f1992fe1ecaf10d65d7adaffe611b3c9
|
|
@@ -10,7 +10,8 @@ module Avm
|
|
|
10
10
|
VALID_TYPES = ['x-ruby'].freeze
|
|
11
11
|
|
|
12
12
|
def internal_apply(files)
|
|
13
|
-
::Avm::EacRubyBase1::Rubocop.new('.',
|
|
13
|
+
::Avm::EacRubyBase1::Rubocop::Runner.new('.',
|
|
14
|
+
['-a', '--ignore-parent-exclusion'] + files).run
|
|
14
15
|
super
|
|
15
16
|
end
|
|
16
17
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class Command
|
|
7
|
+
class Build
|
|
8
|
+
acts_as_instance_method
|
|
9
|
+
common_constructor :owner
|
|
10
|
+
|
|
11
|
+
# @return [EacRubyUtils::Ruby::Command]
|
|
12
|
+
def result
|
|
13
|
+
%i[execution_callback gemfile]
|
|
14
|
+
.inject(::EacRubyUtils::Envs.local.command(*owner.build_args)) do |a, e|
|
|
15
|
+
send("apply_for_#{e}", a)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
protected
|
|
20
|
+
|
|
21
|
+
def apply_for_execution_callback(command)
|
|
22
|
+
command.singleton_class.set_callback :any_execution, :around do |_record, block|
|
|
23
|
+
::EacRubyUtils::Ruby.on_clean_environment do
|
|
24
|
+
block.call
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
command
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def apply_for_gemfile(command)
|
|
31
|
+
owner.gemfile.if_present(command) do |v|
|
|
32
|
+
command.envvar(
|
|
33
|
+
::Avm::EacRubyBase1::Sources::Base::BundleCommand::GEMFILE_PATH_ENVVAR, v
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class Command
|
|
7
|
+
acts_as_immutable
|
|
8
|
+
immutable_accessor :autocorrect_safe, :autocorrect_unsafe, :ignore_parent_exclusion,
|
|
9
|
+
:old_options, type: :boolean
|
|
10
|
+
immutable_accessor :file, type: :array
|
|
11
|
+
immutable_accessor :config, :format, :gemfile, type: :common
|
|
12
|
+
|
|
13
|
+
# @return [String]
|
|
14
|
+
def autocorrect_safe_option
|
|
15
|
+
old_options? ? '--auto-correct' : '--autocorrect'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @return [String]
|
|
19
|
+
def autocorrect_unsafe_option
|
|
20
|
+
old_options? ? '--auto-correct-all' : '--autocorrect-all'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [Array<String>]
|
|
24
|
+
def autocorrect_to_args
|
|
25
|
+
if autocorrect_unsafe?
|
|
26
|
+
[autocorrect_unsafe_option]
|
|
27
|
+
elsif autocorrect_safe?
|
|
28
|
+
[autocorrect_safe_option]
|
|
29
|
+
else
|
|
30
|
+
[]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @return [Array<String>]
|
|
35
|
+
def build_args
|
|
36
|
+
%w[prefix config ignore_parent_exclusion autocorrect format files].inject([]) do |a, e|
|
|
37
|
+
a + send("#{e}_to_args")
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @return [Array<String>]
|
|
42
|
+
def bundle_command_args
|
|
43
|
+
%w[exec rubocop] + rubocop_command_args
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Array<String>]
|
|
47
|
+
def config_to_args
|
|
48
|
+
config.if_present([]) { |v| ['--config', v] }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @return [Array<String>]
|
|
52
|
+
def files_to_args
|
|
53
|
+
files
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @return [Array<String>]
|
|
57
|
+
def format_to_args
|
|
58
|
+
format.if_present([]) { |v| ['--format', v] }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @return [String]
|
|
62
|
+
def ignore_parent_exclusion_option
|
|
63
|
+
'--ignore-parent-exclusion'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @return [Array<String>]
|
|
67
|
+
def ignore_parent_exclusion_to_args
|
|
68
|
+
ignore_parent_exclusion? ? [ignore_parent_exclusion_option] : []
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @return [Array<String>]
|
|
72
|
+
def prefix_to_args
|
|
73
|
+
(gemfile.present? ? %w[bundle exec] : []) + ['rubocop']
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
require_sub __FILE__, require_mode: :kernel
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class OffenseSet
|
|
7
|
+
class File
|
|
8
|
+
class << self
|
|
9
|
+
# @param data [Hash]
|
|
10
|
+
# @return [FileOffenses]
|
|
11
|
+
def by_data(data)
|
|
12
|
+
new(data.fetch('path'), data.fetch('offenses').map do |odata|
|
|
13
|
+
::Avm::EacRubyBase1::Rubocop::OffenseSet::Offense.by_data(odata)
|
|
14
|
+
end)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
common_constructor :path, :offenses do
|
|
19
|
+
self.path = path.to_pathname
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [void]
|
|
23
|
+
def disable_offenses
|
|
24
|
+
path.write(disable_rubocop_content)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @return [Boolean]
|
|
28
|
+
def offenses?
|
|
29
|
+
offenses.any?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# @return [String]
|
|
35
|
+
def disable_rubocop_content
|
|
36
|
+
path.read.each_line.with_index.map do |line, index|
|
|
37
|
+
::Avm::EacRubyBase1::Rubocop::OffenseSet::LineProcessor
|
|
38
|
+
.new(line, line_offenses(index)).result
|
|
39
|
+
end.join
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @param index [Integer]
|
|
43
|
+
# @return [Enumerable<Offense>]
|
|
44
|
+
def line_offenses(index)
|
|
45
|
+
offenses.select { |o| o.line_index == index }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class OffenseSet
|
|
7
|
+
class LineProcessor
|
|
8
|
+
LINE_STRUCT = ::Struct.new(:left, :right)
|
|
9
|
+
LINE_PATTERN = /\A(.+)(?:\#\s*rubocop:disable\s*(.+))?\z/
|
|
10
|
+
|
|
11
|
+
enable_simple_cache
|
|
12
|
+
common_constructor :line, :offenses
|
|
13
|
+
|
|
14
|
+
def result
|
|
15
|
+
r = line_left
|
|
16
|
+
r += " # rubocop:disable #{all_cops.join(',')}" if all_cops.any?
|
|
17
|
+
"#{r}\n"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
# @return [Array<String>]
|
|
23
|
+
def all_cops_uncached
|
|
24
|
+
(current_cops + offenses_cops).uniq.sort
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @return [Array<String>]
|
|
28
|
+
def current_cops
|
|
29
|
+
parsed_line[1].if_present([]) { |s| s.split(',').map(&:strip).select(&:present) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# @return [Array<String>]
|
|
33
|
+
def offenses_cops
|
|
34
|
+
offenses.map(&:cop_name)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def line_left
|
|
38
|
+
parsed_line[0]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @return [LINE_STRUCT]
|
|
42
|
+
def parsed_line_uncached
|
|
43
|
+
m = LINE_PATTERN.match(line)
|
|
44
|
+
if m
|
|
45
|
+
LINE_STRUCT.new(m[1].rstrip, m[2].rstrip)
|
|
46
|
+
else
|
|
47
|
+
LINE_STRUCT.new(line.rstrip, nil)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class OffenseSet
|
|
7
|
+
class Offense
|
|
8
|
+
class << self
|
|
9
|
+
def by_data(data)
|
|
10
|
+
new(data)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
common_constructor :data
|
|
15
|
+
|
|
16
|
+
# @return [String]
|
|
17
|
+
def cop_name
|
|
18
|
+
data.fetch('cop_name')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @return [Integer]
|
|
22
|
+
def line_index
|
|
23
|
+
line_number - 1
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @return [Integer]
|
|
27
|
+
def line_number
|
|
28
|
+
data.fetch('location').fetch('line')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class OffenseSet
|
|
7
|
+
class << self
|
|
8
|
+
# @param json_text [String] The output of `rubocop --format json`.
|
|
9
|
+
# @return [Avm::EacRubyBase1::Rubocop::OffenseSet]
|
|
10
|
+
def from_json(json_text)
|
|
11
|
+
new(
|
|
12
|
+
JSON.parse(json_text).fetch('files').map do |data|
|
|
13
|
+
::Avm::EacRubyBase1::Rubocop::OffenseSet::File.by_data(data)
|
|
14
|
+
end.select(&:offenses?)
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
common_constructor :files
|
|
20
|
+
|
|
21
|
+
# @return [void]
|
|
22
|
+
def disable_all
|
|
23
|
+
files.each(&:disable_offenses)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class Runner
|
|
7
|
+
module Configured
|
|
8
|
+
def configured_rubocop_command_uncached
|
|
9
|
+
configured_rubocop_command_by_command || configured_rubocop_command_by_gemfile
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def configured_rubocop_command_by_command
|
|
13
|
+
configuration.if_present(&:rubocop_command)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def configured_rubocop_command_by_gemfile
|
|
17
|
+
configuration.if_present(&:rubocop_gemfile).if_present do |v|
|
|
18
|
+
rubocop_command_by_gemfile_path(v.parent)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def configuration_uncached
|
|
25
|
+
::Avm::Sources::Configuration.find_by_path(base_path)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class Runner
|
|
7
|
+
module Envvar
|
|
8
|
+
RUBOCOP_COMMAND_ENVVAR_NAME = 'RUBOCOP_COMMAND'
|
|
9
|
+
|
|
10
|
+
def env_rubocop_command
|
|
11
|
+
ENV[RUBOCOP_COMMAND_ENVVAR_NAME].present? ? cmd(ENV[RUBOCOP_COMMAND_ENVVAR_NAME]) : nil
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class Runner
|
|
7
|
+
module Gemfile
|
|
8
|
+
def gemfile_rubocop_command
|
|
9
|
+
return nil unless rubocop_gemfile?
|
|
10
|
+
|
|
11
|
+
rubocop_command_by_gemfile_path(mygem.path)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def rubocop_command_by_gemfile_path(path)
|
|
15
|
+
::Avm::EacRubyBase1::Sources::Base.new(path).bundle('exec', 'rubocop').chdir_root
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def rubocop_gemfile?
|
|
19
|
+
return false if mygem.blank?
|
|
20
|
+
|
|
21
|
+
mygem.bundle('install').execute!
|
|
22
|
+
mygem.gemfile_lock_gem_version('rubocop').present?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def mygem_uncached
|
|
28
|
+
find_gem(::Pathname.new(base_path).expand_path)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def find_gem(path)
|
|
32
|
+
r = ::Avm::EacRubyBase1::Sources::Base.new(path)
|
|
33
|
+
return r if r.gemfile_path.exist?
|
|
34
|
+
|
|
35
|
+
find_gem(path.dirname) unless path.root?
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Rubocop
|
|
6
|
+
class Runner
|
|
7
|
+
require_sub __FILE__, include_modules: true
|
|
8
|
+
enable_speaker
|
|
9
|
+
enable_simple_cache
|
|
10
|
+
common_constructor :base_path, :rubocop_args
|
|
11
|
+
set_callback :initialize, :after do
|
|
12
|
+
@base_path = ::Pathname.new(base_path.to_s) unless base_path.is_a?(::Pathname)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
start_banner
|
|
17
|
+
run_rubocop
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def cmd(*)
|
|
23
|
+
::EacRubyUtils::Envs.local.command(*)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def rubocop_command_uncached
|
|
27
|
+
%w[env configured gemfile].each do |s|
|
|
28
|
+
cmd = send("#{s}_rubocop_command")
|
|
29
|
+
return cmd if cmd.present?
|
|
30
|
+
end
|
|
31
|
+
cmd('rubocop')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def rubocop_command_with_args
|
|
35
|
+
rubocop_command.append(rubocop_args)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def rubocop_version_uncached
|
|
39
|
+
::EacRubyUtils::Ruby.on_clean_environment do
|
|
40
|
+
rubocop_command.append(['--ignore-parent-exclusion', '--version']).execute!.strip
|
|
41
|
+
rescue EacRubyUtils::Envs::ExecutionError
|
|
42
|
+
rubocop_command.append(['--version']).execute!.strip
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def run_rubocop
|
|
47
|
+
::EacRubyUtils::Ruby.on_clean_environment { rubocop_command_with_args.system }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def start_banner
|
|
51
|
+
infov 'Rubocop version', rubocop_version
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -16,6 +16,17 @@ module Avm
|
|
|
16
16
|
def rubocop_config_path
|
|
17
17
|
path.join(RUBOCOP_CONFIG_SUBPATH)
|
|
18
18
|
end
|
|
19
|
+
|
|
20
|
+
# @return [Avm::EacRubyBase1::Rubocop::OffenseSet]
|
|
21
|
+
def rubocop_offenses
|
|
22
|
+
::Avm::EacRubyBase1::Rubocop::OffenseSet
|
|
23
|
+
.from_json(rubocop_root_command.format('json').execute.fetch(:stdout))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# @return [Avm::EacRubyBase1::Sources::Base::RubocopCommand]
|
|
27
|
+
def rubocop_root_command
|
|
28
|
+
rubocop_command.ignore_parent_exclusion(true).file(path)
|
|
29
|
+
end
|
|
19
30
|
end
|
|
20
31
|
end
|
|
21
32
|
end
|
|
@@ -9,6 +9,7 @@ module Avm
|
|
|
9
9
|
immutable_accessor :ignore_parent_exclusion, :autocorrect, :autocorrect_all,
|
|
10
10
|
type: :boolean
|
|
11
11
|
immutable_accessor :file, type: :array
|
|
12
|
+
immutable_accessor :format, type: :common
|
|
12
13
|
common_constructor :source
|
|
13
14
|
delegate :execute, :execute!, :system, :system!, to: :bundle_command
|
|
14
15
|
|
|
@@ -20,48 +21,28 @@ module Avm
|
|
|
20
21
|
# @return [Gemspec::Version]
|
|
21
22
|
def version
|
|
22
23
|
@version ||= ::Gem::Version.new(
|
|
23
|
-
|
|
24
|
+
rubocop_command.extra_arg('--version').build.execute!
|
|
24
25
|
)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
private
|
|
28
29
|
|
|
29
|
-
# @return [
|
|
30
|
-
def
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def bundle_command
|
|
46
|
-
source.bundle(*bundle_command_args)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# @return [Array<String>]
|
|
50
|
-
def bundle_command_args
|
|
51
|
-
%w[exec rubocop] + rubocop_command_args
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# @return [Array<String>]
|
|
55
|
-
def rubocop_command_args
|
|
56
|
-
r = []
|
|
57
|
-
r += ['--config', source.rubocop_config_path] if source.rubocop_config_path.file?
|
|
58
|
-
r << ignore_parent_exclusion_option if ignore_parent_exclusion?
|
|
59
|
-
if autocorrect_all?
|
|
60
|
-
r << autocorrect_all_option
|
|
61
|
-
elsif autocorrect?
|
|
62
|
-
r << autocorrect_option
|
|
63
|
-
end
|
|
64
|
-
r + files
|
|
30
|
+
# @return [EacRubyUtils::Ruby::Command]
|
|
31
|
+
def bundle_command # rubocop:disable Metrics/AbcSize
|
|
32
|
+
r = rubocop_command
|
|
33
|
+
.autocorrect_safe(autocorrect?)
|
|
34
|
+
.autocorrect_unsafe(autocorrect_all?)
|
|
35
|
+
.files(files)
|
|
36
|
+
.format(format)
|
|
37
|
+
.gemfile(source.gemfile_path)
|
|
38
|
+
.ignore_parent_exclusion(ignore_parent_exclusion)
|
|
39
|
+
r = r.config(source.rubocop_config_path) if source.rubocop_config_path.file?
|
|
40
|
+
r.build
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @return [Avm::EacRubyBase1::Rubocop::Command]
|
|
44
|
+
def rubocop_command
|
|
45
|
+
::Avm::EacRubyBase1::Rubocop::Command.new.gemfile(source.gemfile_path)
|
|
65
46
|
end
|
|
66
47
|
end
|
|
67
48
|
end
|
|
@@ -13,7 +13,8 @@ module Avm
|
|
|
13
13
|
# @param changes [Enumerable<Avm::Sources::Change>]
|
|
14
14
|
def update_self_changes_after_subs
|
|
15
15
|
super + [
|
|
16
|
-
::Avm::EacRubyBase1::Sources::Update::Changes::UpdateRequirements.new(self)
|
|
16
|
+
::Avm::EacRubyBase1::Sources::Update::Changes::UpdateRequirements.new(self),
|
|
17
|
+
::Avm::EacRubyBase1::Sources::Update::Changes::RubocopFormat.new(self)
|
|
17
18
|
]
|
|
18
19
|
end
|
|
19
20
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Avm
|
|
4
|
+
module EacRubyBase1
|
|
5
|
+
module Sources
|
|
6
|
+
module Update
|
|
7
|
+
module Changes
|
|
8
|
+
class RubocopFormat < ::Avm::Sources::Change
|
|
9
|
+
# @return [void]
|
|
10
|
+
def perform
|
|
11
|
+
return if autofix
|
|
12
|
+
|
|
13
|
+
disable_offenses
|
|
14
|
+
autofix
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @return [Boolean]
|
|
18
|
+
def autofix
|
|
19
|
+
source.rubocop_root_command.autocorrect(true).system
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [void]
|
|
23
|
+
def disable_offenses
|
|
24
|
+
source.rubocop_offenses.disable_all
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -31,7 +31,7 @@ module Avm
|
|
|
31
31
|
|
|
32
32
|
# @return [String]
|
|
33
33
|
def format_gemspec
|
|
34
|
-
source.
|
|
34
|
+
source.rubocop_root_command.autocorrect(true)
|
|
35
35
|
.file(source.gemspec_path)
|
|
36
36
|
.execute!(exit_outputs: RUBOCOP_OK_CODES.index_with { |_k| nil })
|
|
37
37
|
end
|
data/locale/en.yml
CHANGED
data/locale/pt-BR.yml
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: avm-eac_ruby_base1
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.45.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Put here the authors
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
version: '0.102'
|
|
33
33
|
- - ">="
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 0.102.
|
|
35
|
+
version: 0.102.4
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -42,7 +42,7 @@ dependencies:
|
|
|
42
42
|
version: '0.102'
|
|
43
43
|
- - ">="
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 0.102.
|
|
45
|
+
version: 0.102.4
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: avm-eac_generic_base0
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -148,10 +148,16 @@ files:
|
|
|
148
148
|
- lib/avm/eac_ruby_base1/preferred_version_requirements.rb
|
|
149
149
|
- lib/avm/eac_ruby_base1/rspec/setup.rb
|
|
150
150
|
- lib/avm/eac_ruby_base1/rspec/source_generator.rb
|
|
151
|
-
- lib/avm/eac_ruby_base1/rubocop.rb
|
|
152
|
-
- lib/avm/eac_ruby_base1/rubocop/
|
|
153
|
-
- lib/avm/eac_ruby_base1/rubocop/
|
|
154
|
-
- lib/avm/eac_ruby_base1/rubocop/
|
|
151
|
+
- lib/avm/eac_ruby_base1/rubocop/command.rb
|
|
152
|
+
- lib/avm/eac_ruby_base1/rubocop/command/build.rb
|
|
153
|
+
- lib/avm/eac_ruby_base1/rubocop/offense_set.rb
|
|
154
|
+
- lib/avm/eac_ruby_base1/rubocop/offense_set/file.rb
|
|
155
|
+
- lib/avm/eac_ruby_base1/rubocop/offense_set/line_processor.rb
|
|
156
|
+
- lib/avm/eac_ruby_base1/rubocop/offense_set/offense.rb
|
|
157
|
+
- lib/avm/eac_ruby_base1/rubocop/runner.rb
|
|
158
|
+
- lib/avm/eac_ruby_base1/rubocop/runner/configured.rb
|
|
159
|
+
- lib/avm/eac_ruby_base1/rubocop/runner/envvar.rb
|
|
160
|
+
- lib/avm/eac_ruby_base1/rubocop/runner/gemfile.rb
|
|
155
161
|
- lib/avm/eac_ruby_base1/rubygems/gem_search_parser.rb
|
|
156
162
|
- lib/avm/eac_ruby_base1/rubygems/gemspec.rb
|
|
157
163
|
- lib/avm/eac_ruby_base1/rubygems/gemspec/add_or_replace_gem_line.rb
|
|
@@ -201,6 +207,7 @@ files:
|
|
|
201
207
|
- lib/avm/eac_ruby_base1/sources/tests/multiple/result.rb
|
|
202
208
|
- lib/avm/eac_ruby_base1/sources/tests/rspec.rb
|
|
203
209
|
- lib/avm/eac_ruby_base1/sources/update/changes/bundle_update.rb
|
|
210
|
+
- lib/avm/eac_ruby_base1/sources/update/changes/rubocop_format.rb
|
|
204
211
|
- lib/avm/eac_ruby_base1/sources/update/changes/update_requirements.rb
|
|
205
212
|
- lib/avm/eac_ruby_base1/sources/update/sub_update.rb
|
|
206
213
|
- lib/avm/eac_ruby_base1/version.rb
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Avm
|
|
4
|
-
module EacRubyBase1
|
|
5
|
-
class Rubocop
|
|
6
|
-
module Configured
|
|
7
|
-
def configured_rubocop_command_uncached
|
|
8
|
-
configured_rubocop_command_by_command || configured_rubocop_command_by_gemfile
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def configured_rubocop_command_by_command
|
|
12
|
-
configuration.if_present(&:rubocop_command)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def configured_rubocop_command_by_gemfile
|
|
16
|
-
configuration.if_present(&:rubocop_gemfile).if_present do |v|
|
|
17
|
-
rubocop_command_by_gemfile_path(v.parent)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def configuration_uncached
|
|
24
|
-
::Avm::Sources::Configuration.find_by_path(base_path)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Avm
|
|
4
|
-
module EacRubyBase1
|
|
5
|
-
class Rubocop
|
|
6
|
-
module Envvar
|
|
7
|
-
RUBOCOP_COMMAND_ENVVAR_NAME = 'RUBOCOP_COMMAND'
|
|
8
|
-
|
|
9
|
-
def env_rubocop_command
|
|
10
|
-
ENV[RUBOCOP_COMMAND_ENVVAR_NAME].present? ? cmd(ENV[RUBOCOP_COMMAND_ENVVAR_NAME]) : nil
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Avm
|
|
4
|
-
module EacRubyBase1
|
|
5
|
-
class Rubocop
|
|
6
|
-
module Gemfile
|
|
7
|
-
def gemfile_rubocop_command
|
|
8
|
-
return nil unless rubocop_gemfile?
|
|
9
|
-
|
|
10
|
-
rubocop_command_by_gemfile_path(mygem.path)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def rubocop_command_by_gemfile_path(path)
|
|
14
|
-
::Avm::EacRubyBase1::Sources::Base.new(path).bundle('exec', 'rubocop').chdir_root
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def rubocop_gemfile?
|
|
18
|
-
return false if mygem.blank?
|
|
19
|
-
|
|
20
|
-
mygem.bundle('install').execute!
|
|
21
|
-
mygem.gemfile_lock_gem_version('rubocop').present?
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def mygem_uncached
|
|
27
|
-
find_gem(::Pathname.new(base_path).expand_path)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def find_gem(path)
|
|
31
|
-
r = ::Avm::EacRubyBase1::Sources::Base.new(path)
|
|
32
|
-
return r if r.gemfile_path.exist?
|
|
33
|
-
|
|
34
|
-
find_gem(path.dirname) unless path.root?
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Avm
|
|
4
|
-
module EacRubyBase1
|
|
5
|
-
class Rubocop
|
|
6
|
-
require_sub __FILE__, include_modules: true
|
|
7
|
-
enable_speaker
|
|
8
|
-
enable_simple_cache
|
|
9
|
-
common_constructor :base_path, :rubocop_args
|
|
10
|
-
set_callback :initialize, :after do
|
|
11
|
-
@base_path = ::Pathname.new(base_path.to_s) unless base_path.is_a?(::Pathname)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def run
|
|
15
|
-
start_banner
|
|
16
|
-
run_rubocop
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def cmd(*)
|
|
22
|
-
::EacRubyUtils::Envs.local.command(*)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def rubocop_command_uncached
|
|
26
|
-
%w[env configured gemfile].each do |s|
|
|
27
|
-
cmd = send("#{s}_rubocop_command")
|
|
28
|
-
return cmd if cmd.present?
|
|
29
|
-
end
|
|
30
|
-
cmd('rubocop')
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def rubocop_command_with_args
|
|
34
|
-
rubocop_command.append(rubocop_args)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def rubocop_version_uncached
|
|
38
|
-
::EacRubyUtils::Ruby.on_clean_environment do
|
|
39
|
-
rubocop_command.append(['--ignore-parent-exclusion', '--version']).execute!.strip
|
|
40
|
-
rescue EacRubyUtils::Envs::ExecutionError
|
|
41
|
-
rubocop_command.append(['--version']).execute!.strip
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def run_rubocop
|
|
46
|
-
::EacRubyUtils::Ruby.on_clean_environment { rubocop_command_with_args.system }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def start_banner
|
|
50
|
-
infov 'Rubocop version', rubocop_version
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|