nucop 0.1.2 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9fc165f5dbcc9624bfd5ed3c1c372f3f81ff325ca44d59990c4db36a2f0da39
4
- data.tar.gz: a10769b0dc3d5de55c23442b4d27ea6bedecde3db859b3e679b5583c2b3e9846
3
+ metadata.gz: 40f334562fcb3d2ff95256e19d78f2f33ab300a155814d11dae6d5aa7d2c6f3e
4
+ data.tar.gz: 61b561150890b4f2cd0ec877ebaaf11468af19a1087e5a0ebbb7791a7bec9c26
5
5
  SHA512:
6
- metadata.gz: 43218b9441df727be126479a83813cbfc048af1a472f1fc1a5dc365871eaad0cf95bab8b091abf34238243dd3f3843fe0d0408a57e59a17193de288f0e2ed697
7
- data.tar.gz: 986be2c74320253d2746d25229fd9ad724f61029e1200d7b447b7373aa83ec813921af6bd3745eff5d0cd92e5f51c69a7176881bde42a2f95526cfc1311bd6ab
6
+ metadata.gz: c5d7935525a7f3e71779314e40de44e5a65efeed0a878a4340ec88cb030d54bc40c34e7dc2d00923d0ee272aa9be9ac7d52d9ea641b85e8f007068dfe0d067d7
7
+ data.tar.gz: 327247f6c795b46fda02787e460d6a4a38e8e8464f5c4ae73dad4709a1694a398d6926fe86d25465b8ed768a73d5b24734031928260fb3777e83a2a59f2a96fc
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.1.2"
2
+ VERSION = "0.3.2"
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.1.2
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Schweier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2020-07-13 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.88.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.88.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.0
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.0
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.75.1
61
+ version: 2.6.0
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.75.1
68
+ version: 2.6.0
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.0
75
+ version: 1.42.0
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.0
82
+ version: 1.42.0
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.3.2
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.3.2
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.36.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.36.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
@@ -148,9 +148,14 @@ files:
148
148
  - lib/nucop/helpers/next_cop_for_promotion.rb
149
149
  - lib/nucop/version.rb
150
150
  - spec/spec_helper.rb
151
- homepage:
152
- licenses: []
153
- metadata: {}
151
+ homepage: https://rubygems.org/gems/nucop
152
+ licenses:
153
+ - MIT
154
+ metadata:
155
+ homepage_uri: https://github.com/nulogy/nucop
156
+ changelog_uri: https://github.com/nulogy/nucop/blob/master/CHANGELOG.md
157
+ source_code_uri: https://github.com/nulogy/nucop
158
+ bug_tracker_uri: https://github.com/nulogy/nucop/issues
154
159
  post_install_message:
155
160
  rdoc_options: []
156
161
  require_paths:
@@ -166,8 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
171
  - !ruby/object:Gem::Version
167
172
  version: '0'
168
173
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.7.6
174
+ rubygems_version: 3.1.4
171
175
  signing_key:
172
176
  specification_version: 4
173
177
  summary: Nulogy's implementation of RuboCop, including custom cops and additional