yast-rake 0.2.43 → 0.2.44

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/tasks/rubocop.rake +34 -14
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 183bdc451acadf652d5ef8d5749b166770f3664b2f73139cadab86f59b35f9e7
4
- data.tar.gz: 86a255dfe87bb4b38128568e04752e4a111c2840bbd880499a12f6f0447e3e71
3
+ metadata.gz: b131d89f00dea687fc5d44232d1cf6ce503659ca2ca810d63b17169d69eb5e00
4
+ data.tar.gz: 1e2d455ac8ca10a363b7bf89585f8bf0927dd06c94204d222a1384f421b4270d
5
5
  SHA512:
6
- metadata.gz: 778c1d1c7e5258ce439e0e6d16ec01b0eb20cbb1ac4a7260f497a1256b189865d5d594ba4f1dbf18b9dc6accbaf2430ccb4f3510b19c7a65ae0b56ff5a06c8c0
7
- data.tar.gz: 848c641d6d94d8b40a610d575b4fc0f63df0942b5fe0987663511d11761278ddb560e8e86d1a20a19b3b5529be2b012c9cc4f7d593934613e6832366e1eaaa42
6
+ metadata.gz: 5a83c6e94d862c23c0f04e84cdf68d48c0aa4b4f51caba4000a6f5106831097c38343b10a553fc83fd3355e37a9b719befab007656b3a1626b2364b76f8db35a
7
+ data.tar.gz: 13828bd3771752722aa0fe5eb0c7f8f305b6f447bf8f0310e71c5df33e4810d5f071fa2cdef39cbcdfc17a2eff2e9e4e12b2f37675aff1c6fbda0d5d4b1b9a24
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.43
1
+ 0.2.44
@@ -15,12 +15,24 @@
15
15
  #
16
16
  #++
17
17
 
18
+ # the default old version used
19
+ OLD_RUBOCOP_VERSION = "0.41.2"
20
+
21
+ def rubocop_version
22
+ return @rubocop_version if @rubocop_version
23
+
24
+ @rubocop_version = if File.read(".rubocop.yml").match(/rubocop-(\d+\.\d+\.\d+)/)
25
+ Regexp.last_match[1]
26
+ else
27
+ OLD_RUBOCOP_VERSION
28
+ end
29
+ end
30
+
18
31
  def rubocop_bin
19
32
  return @rubocop_bin if @rubocop_bin
20
33
  return @rubocop_bin = ENV["RUBOCOP_BIN"] if ENV["RUBOCOP_BIN"]
21
34
 
22
- version = File.read(".rubocop.yml").include?("rubocop-0.71.0") ? "0.71.0" : "0.41.2"
23
- binary = `/usr/sbin/update-alternatives --list rubocop | grep '#{version}'`.strip
35
+ binary = `/usr/sbin/update-alternatives --list rubocop | grep '#{rubocop_version}'`.strip
24
36
  if !system("which #{binary}")
25
37
  raise "cannot find proper version of rubocop binary in " \
26
38
  "'/usr/sbin/update-alternatives --list rubocop'." \
@@ -32,18 +44,26 @@ end
32
44
  # run Rubocop in parallel
33
45
  # @param params [String] optional Rubocop parameters
34
46
  def run_rubocop(params = "")
35
- # how it works:
36
- # 1) get the list of inspected files by Rubocop
37
- # 2) shuffle it randomly (better would be evenly distribute them according to
38
- # the analysis complexity but that is hard to evaluate and even simply
39
- # distributing by file size turned out to be ineffective and slower than
40
- # a simple random shuffling)
41
- # 3) pass that as input for xargs
42
- # a) use -P with number of processors to run the commands in parallel
43
- # b) use -n to set the maximum number of files per process, this number
44
- # is computed to equally distribute the files across the workers
45
- sh "#{rubocop_bin} -L | sort -R | xargs -P`nproc` -n$(expr `#{rubocop_bin} -L | wc -l` / " \
46
- "`nproc` + 1) #{rubocop_bin} #{params}"
47
+ # newer Rubocop versions support the "-P" ("--parallel") option,
48
+ # but that is not compatible with the "-a" ("--auto-correct") option
49
+ if rubocop_version != OLD_RUBOCOP_VERSION && !params.to_s.match(/-a|--auto-correct/)
50
+ sh "#{rubocop_bin} -P #{params}"
51
+ else
52
+ # for older Rubocop or auto-correct mode manually start multiple instances in parallel
53
+ #
54
+ # how it works:
55
+ # 1) get the list of inspected files by Rubocop
56
+ # 2) shuffle it randomly (better would be evenly distribute them according to
57
+ # the analysis complexity but that is hard to evaluate and even simply
58
+ # distributing by file size turned out to be ineffective and slower than
59
+ # a simple random shuffling)
60
+ # 3) pass that as input for xargs
61
+ # a) use -P with number of processors to run the commands in parallel
62
+ # b) use -n to set the maximum number of files per process, this number
63
+ # is computed to equally distribute the files across the workers
64
+ sh "#{rubocop_bin} -L | sort -R | xargs -P`nproc` -n$(expr `#{rubocop_bin} -L | wc -l` / " \
65
+ "`nproc` + 1) #{rubocop_bin} #{params}"
66
+ end
47
67
  end
48
68
 
49
69
  namespace :check do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yast-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.43
4
+ version: 0.2.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Reidinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packaging_rake_tasks