nucop 0.2.0 → 0.3.3

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: 96431415f4ba9ffdeccc8b3f831946afb8d32326b680b4c015061ad66038a89a
4
- data.tar.gz: 713830bb560b1dd38cf70409e57f0a8af2616f9cac5e6c52c5429db89dbd6242
3
+ metadata.gz: 4e4d4bc70ff2bafe59ff5f5d0f139076cb223f45127c0af10879d7ca59e6ad58
4
+ data.tar.gz: 1eb6b93afe63711f4663959b62fc584d86b8f0cb2808311018b3fb125c312c30
5
5
  SHA512:
6
- metadata.gz: 903b54b802f7d86f1476eb675785dfa251ae03a6b731d7e1069ca45df405d2ec3a4a84cdfb4e8411bfc3ef22e1a16f93c81c77f65031091b16255b21c7d21823
7
- data.tar.gz: 95ef89faf62bb7528b88362d44e408ed793829f7993c1a6885e184e43c591e26d364a6a7a0119216fc2910dc3ca9f8b185acb76d27d46793a7391083cc0b866f
6
+ metadata.gz: 9718086bfdf283e30fa209b9ca997092f2eca1c417cc259e0490d1f25a02ca18103e3a8a6c07019a196889b854bbb1137000e46b3c626d70d451033923142713
7
+ data.tar.gz: c5d56ef473496fadc2a544e6cdd1f2faf6ab83c0b94c0324aa9cfeb00b46be41769314479f7202fcf285edcb8fa8d2f7543ba0df31f1eec6d3c5c27fec40accd
data/bin/nucop CHANGED
@@ -5,4 +5,4 @@ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
5
  require "nucop"
6
6
  require "nucop/cli"
7
7
 
8
- Nucop::CLI.start(ARGV)
8
+ Nucop::Cli.start(ARGV)
@@ -3,9 +3,9 @@ require "nucop/version"
3
3
  require "rubocop"
4
4
  require "git_diff_parser"
5
5
 
6
- Dir[File.join(__dir__, "nucop/helpers/**/*.rb")].each { |f| require f }
7
- Dir[File.join(__dir__, "nucop/formatters/**/*.rb")].each { |f| require f }
8
- Dir[File.join(__dir__, "nucop/cops/**/*.rb")].each { |f| require f }
6
+ Dir[File.join(__dir__, "nucop/helpers/**/*.rb")].sort.each { |f| require f }
7
+ Dir[File.join(__dir__, "nucop/formatters/**/*.rb")].sort.each { |f| require f }
8
+ Dir[File.join(__dir__, "nucop/cops/**/*.rb")].sort.each { |f| require f }
9
9
 
10
10
  module Nucop
11
11
  end
@@ -5,11 +5,12 @@ RUBOCOP_DEFAULT_CONFIG_FILE = ".rubocop.yml"
5
5
  CONFIGURATION_FILEPATH = ".nucop.yml"
6
6
 
7
7
  module Nucop
8
- class CLI < Thor
8
+ class Cli < Thor
9
9
  desc "diff_enforced", "run RuboCop on the current diff using only the enforced cops"
10
10
  method_option "commit-spec", default: "origin/master", desc: "the commit used to determine the diff."
11
11
  method_option "auto-correct", type: :boolean, default: false, desc: "runs RuboCop with auto-correct option"
12
- method_option "junit_report", type: :string, default: "", desc: "runs RuboCop with junit formatter option"
12
+ method_option "junit_report", type: :string, default: nil, desc: "runs RuboCop with junit formatter option"
13
+ method_option "json", type: :string, default: nil, desc: "Output results as JSON format to the provided file"
13
14
  def diff_enforced
14
15
  invoke :diff, nil, options.merge(only: cops_to_enforce.join(","))
15
16
  end
@@ -66,16 +67,30 @@ module Nucop
66
67
  def rubocop(files = nil)
67
68
  print_cops_being_run(options[:only])
68
69
  config_file = options[:"exclude-backlog"] ? RUBOCOP_DEFAULT_CONFIG_FILE : options[:rubocop_todo_config_file]
69
- junit_report_path = options[:"junit_report"]
70
- junit_report_options = junit_report_path.to_s.empty? ? "" : "--format Nucop::Formatters::JUnitFormatter --out #{junit_report_path} --format progress"
71
-
72
70
  rubocop_requires = [
73
71
  "--require rubocop-rspec",
74
72
  "--require rubocop-performance",
75
73
  "--require rubocop-rails"
76
74
  ]
77
75
 
78
- system("bundle exec rubocop --parallel #{rubocop_requires.join(' ')} #{junit_report_options} --force-exclusion --config #{config_file} #{pass_through_option(options, 'auto-correct')} #{pass_through_flag(options, 'only')} #{files}")
76
+ formatters = []
77
+ formatters << "--format Nucop::Formatters::JUnitFormatter --out #{options[:junit_report]}" if options[:junit_report]
78
+ formatters << "--format json --out #{options[:json]}" if options[:json]
79
+ formatters << "--format progress" if formatters.any?
80
+
81
+ command = [
82
+ "bundle exec rubocop",
83
+ "--parallel",
84
+ rubocop_requires.join(" "),
85
+ formatters.join(" "),
86
+ "--force-exclusion",
87
+ "--config", config_file,
88
+ pass_through_option(options, "auto-correct"),
89
+ pass_through_flag(options, "only"),
90
+ files
91
+ ].join(" ")
92
+
93
+ system(command)
79
94
  end
80
95
 
81
96
  desc "regen_backlog", "update the RuboCop backlog, disabling offending files and excluding all cops with over 500 violating files."
@@ -235,7 +250,9 @@ module Nucop
235
250
  end
236
251
 
237
252
  def enabled_cops
238
- YAML.load(`bundle exec rubocop --parallel --show-cops`).select { |_, config| config["Enabled"] }.map(&:first)
253
+ YAML.load(`bundle exec rubocop --parallel --show-cops`) # rubocop:disable Security/YAMLLoad
254
+ .select { |_, config| config["Enabled"] }
255
+ .map(&:first)
239
256
  end
240
257
 
241
258
  # Override Thor's options method to include Nucop's options
@@ -21,16 +21,17 @@ module Nucop
21
21
  # One test case per cop per file
22
22
  COPS.each do |cop|
23
23
  cop_offences = offences.select { |offence| offence.cop_name == cop.cop_name }
24
- unless cop_offences.empty?
25
- REXML::Element.new("testcase", @testsuite).tap do |f|
26
- f.attributes["classname"] = file.gsub(/\.rb\Z/, "").gsub("#{Dir.pwd}/", "").tr("/", ".")
27
- f.attributes["name"] = "Rubocop: #{cop.cop_name}"
28
- f.attributes["file"] = cop.cop_name
29
- cop_offences.each do |offence|
30
- REXML::Element.new("failure", f).tap do |e|
31
- e.add_text("#{offence.message}\n\n")
32
- e.add_text(offence.location.to_s.sub("/usr/src/app/", ""))
33
- end
24
+
25
+ next if cop_offences.empty?
26
+
27
+ REXML::Element.new("testcase", @testsuite).tap do |f|
28
+ f.attributes["classname"] = file.gsub(/\.rb\Z/, "").gsub("#{Dir.pwd}/", "").tr("/", ".")
29
+ f.attributes["name"] = "Rubocop: #{cop.cop_name}"
30
+ f.attributes["file"] = cop.cop_name
31
+ cop_offences.each do |offence|
32
+ REXML::Element.new("failure", f).tap do |e|
33
+ e.add_text("#{offence.message}\n\n")
34
+ e.add_text(offence.location.to_s.sub("/usr/src/app/", ""))
34
35
  end
35
36
  end
36
37
  end
@@ -1,7 +1,7 @@
1
1
  module Nucop
2
2
  module Helpers
3
3
  module FactoryBotHelper
4
- extend self
4
+ module_function
5
5
 
6
6
  FACTORY_BOT_METHODS = [
7
7
  :build,
@@ -30,7 +30,7 @@ module Nucop
30
30
  data << count_match.captures.first
31
31
  end
32
32
 
33
- if (name_match = line.match(/^(\w+[\/]\w+):$/))
33
+ if (name_match = line.match(/^(\w+\/\w+):$/))
34
34
  data << name_match.captures.first
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module Nucop
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,127 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nucop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Schweier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-19 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: git_diff_parser
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 13.0.0
20
- type: :development
19
+ version: '3.2'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 13.0.0
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.9.0
34
- type: :development
33
+ version: 0.90.0
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.9.0
40
+ version: 0.90.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: git_diff_parser
42
+ name: rubocop-performance
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '3.2'
47
+ version: 1.7.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: '3.2'
54
+ version: 1.7.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: rubocop
56
+ name: rubocop-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.79.0
61
+ version: 2.7.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.79.0
68
+ version: 2.7.1
69
69
  - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
70
+ name: rubocop-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 1.5.2
75
+ version: 1.43.2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 1.5.2
82
+ version: 1.43.2
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop-rails
84
+ name: ruby-progressbar
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '='
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.4.1
89
+ version: '1.10'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '='
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.4.1
96
+ version: '1.10'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rubocop-rspec
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '='
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.37.0
104
- type: :runtime
103
+ version: 13.0.1
104
+ type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '='
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.37.0
110
+ version: 13.0.1
111
111
  - !ruby/object:Gem::Dependency
112
- name: ruby-progressbar
112
+ name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.10'
118
- type: :runtime
117
+ version: 3.9.0
118
+ type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.10'
124
+ version: 3.9.0
125
125
  description:
126
126
  email:
127
127
  - jasons@nulogy.com
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.1.2
174
+ rubygems_version: 3.1.4
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Nulogy's implementation of RuboCop, including custom cops and additional