ndr_dev_support 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +10 -0
- data/.rubocop.yml +7 -4
- data/code_safety.yml +8 -4
- data/lib/ndr_dev_support/version.rb +1 -1
- data/lib/tasks/audit_code.rake +38 -33
- data/ndr_dev_support.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b462909165b10c8d687b0748b757ee8a797766bc
|
4
|
+
data.tar.gz: bfaa3539a90a7b010f81e12d31c2852a25f1a6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 202df7fbda561139125efae9eeb3ba6e1753c0252c8e3097a6febb0668a81e866bb2daf1ba8f6480dafb6ecd37cabd1123d7f1a798869ef825a21ea7336f428f
|
7
|
+
data.tar.gz: abf58184c149a5053dc394ef41184e54b733a4fe5aaa01be61b3455f11765c5d1aabf91af8a927efdff74d83a3dbcfcbafeac72dc1ceb9ee00fb8cc7216fb26e
|
data/.hound.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -35,8 +35,8 @@ Style/FrozenStringLiteralComment:
|
|
35
35
|
# We're not confident enough to make this recommendation everywhere
|
36
36
|
Enabled: false
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
Metrics/LineLength:
|
39
|
+
Max: 100
|
40
40
|
|
41
41
|
Style/ModuleFunction:
|
42
42
|
# `extend self` has fewer side effects than `module_function`.
|
@@ -50,8 +50,11 @@ Style/SingleLineBlockParams:
|
|
50
50
|
# Prefer readability of contextually-named variables.
|
51
51
|
Enabled: false
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
####################### Performance ############################
|
54
|
+
|
55
|
+
# Disagree; readabilty trumps here IMO.
|
56
|
+
Performance/Casecmp:
|
57
|
+
Enabled: false
|
55
58
|
|
56
59
|
##################### Metrics ##################################
|
57
60
|
# NOTE: we bump some metrics by 50%, in recognition of Rubocop's
|
data/code_safety.yml
CHANGED
@@ -4,10 +4,14 @@ file safety:
|
|
4
4
|
comments:
|
5
5
|
reviewed_by: timgentry
|
6
6
|
safe_revision: c59a45986f8b6d087c8c21b1e889f31f7346da17
|
7
|
+
".hound.yml":
|
8
|
+
comments:
|
9
|
+
reviewed_by: timgentry
|
10
|
+
safe_revision: c03d4ff0dd037a2798563d464d0daeca1189debe
|
7
11
|
".rubocop.yml":
|
8
12
|
comments:
|
9
13
|
reviewed_by: timgentry
|
10
|
-
safe_revision:
|
14
|
+
safe_revision: ac89be1deb3d47e9fb00ac2de424116593012074
|
11
15
|
".travis.yml":
|
12
16
|
comments:
|
13
17
|
reviewed_by: josh.pencheon
|
@@ -87,12 +91,12 @@ file safety:
|
|
87
91
|
lib/ndr_dev_support/version.rb:
|
88
92
|
comments:
|
89
93
|
reviewed_by: timgentry
|
90
|
-
safe_revision:
|
94
|
+
safe_revision: fde5bc348b5393ab95b8f0e8d5cae9df29a85f34
|
91
95
|
lib/tasks/audit_code.rake:
|
92
96
|
comments: Identical to the version reviewed by josh.pencheon when contained within
|
93
97
|
ndr_support
|
94
98
|
reviewed_by: timgentry
|
95
|
-
safe_revision:
|
99
|
+
safe_revision: 4813e92fc951a3c033c08c848a9e07e8d5867133
|
96
100
|
lib/tasks/rubocop.rake:
|
97
101
|
comments:
|
98
102
|
reviewed_by: josh.pencheon
|
@@ -100,7 +104,7 @@ file safety:
|
|
100
104
|
ndr_dev_support.gemspec:
|
101
105
|
comments:
|
102
106
|
reviewed_by: timgentry
|
103
|
-
safe_revision:
|
107
|
+
safe_revision: ac89be1deb3d47e9fb00ac2de424116593012074
|
104
108
|
test/ndr_dev_support_test.rb:
|
105
109
|
comments:
|
106
110
|
reviewed_by: timgentry
|
data/lib/tasks/audit_code.rake
CHANGED
@@ -13,6 +13,11 @@ SAFETY_FILE =
|
|
13
13
|
# Temporary overrides to only audit external access files
|
14
14
|
SAFETY_REPOS = [['/svn/era', '/svn/extra/era/external-access']]
|
15
15
|
|
16
|
+
# Returns the (Bundler aware) rake command
|
17
|
+
def rake_cmd
|
18
|
+
ENV['BUNDLE_BIN_PATH'] ? 'bundle exec rake' : 'rake'
|
19
|
+
end
|
20
|
+
|
16
21
|
# Parameter max_print is number of entries to print before truncating output
|
17
22
|
# (negative value => print all)
|
18
23
|
def audit_code_safety(max_print = 20, ignore_new = false, show_diffs = false, show_in_priority = false, user_name = 'usr')
|
@@ -57,7 +62,8 @@ def audit_code_safety(max_print = 20, ignore_new = false, show_diffs = false, sh
|
|
57
62
|
file_safety[f] = {
|
58
63
|
'comments' => nil,
|
59
64
|
'reviewed_by' => nil,
|
60
|
-
'safe_revision' => nil
|
65
|
+
'safe_revision' => nil
|
66
|
+
}
|
61
67
|
end
|
62
68
|
File.open(SAFETY_FILE, 'w') do |file|
|
63
69
|
# Consistent file diffs, as ruby preserves Hash insertion order since v1.9
|
@@ -72,19 +78,19 @@ def audit_code_safety(max_print = 20, ignore_new = false, show_diffs = false, sh
|
|
72
78
|
puts "Number of new files added: #{file_safety.size - orig_count}"
|
73
79
|
|
74
80
|
missing_files = file_safety.keys.reject { |path| File.file?(path) }
|
75
|
-
|
81
|
+
|
76
82
|
if missing_files.length > 0
|
77
83
|
puts "Number of files no longer in repository but in code_safety.yml: #{missing_files.length}"
|
78
|
-
puts " Please run
|
79
|
-
missing_files.each { |path| puts
|
84
|
+
puts " Please run #{rake_cmd} audit:tidy_code_safety_file to remove redundant files"
|
85
|
+
missing_files.each { |path| puts ' ' + path }
|
80
86
|
end
|
81
87
|
|
82
88
|
# Now generate statistics:
|
83
89
|
unknown = file_safety.values.select { |x| x['safe_revision'].nil? }
|
84
90
|
unsafe = file_safety.values.select do |x|
|
85
91
|
!x['safe_revision'].nil? && x['safe_revision'] != -1 &&
|
86
|
-
|
87
|
-
|
92
|
+
x['last_changed_rev'] != x['safe_revision'] &&
|
93
|
+
!(x['last_changed_rev'] =~ /^[0-9]+$/ && x['safe_revision'] =~ /^[0-9]+$/ &&
|
88
94
|
x['last_changed_rev'].to_i < x['safe_revision'].to_i)
|
89
95
|
end
|
90
96
|
puts "Number of files with no safe version: #{unknown.size}"
|
@@ -196,7 +202,7 @@ def repository_type
|
|
196
202
|
@repository_type ||= if Dir.exist?('.svn') || system("svn info . > /dev/null 2>&1")
|
197
203
|
'svn'
|
198
204
|
elsif Dir.exist?('.git') && open('.git/config').grep(/svn/).any?
|
199
|
-
'git-svn'
|
205
|
+
'git-svn'
|
200
206
|
elsif Dir.exist?('.git') && open('.git/config').grep(/git/).any?
|
201
207
|
'git'
|
202
208
|
else
|
@@ -209,17 +215,17 @@ def get_trunk_repo
|
|
209
215
|
when 'svn'
|
210
216
|
repo_info = %x[svn info]
|
211
217
|
puts 'svn case'
|
212
|
-
|
218
|
+
repo_info.split("\n").select { |x| x =~ /^URL: / }.collect { |x| x[5..-1] }.first
|
213
219
|
when 'git-svn'
|
214
220
|
puts 'git-svn case'
|
215
221
|
repo_info = %x[git svn info]
|
216
|
-
|
222
|
+
repo_info.split("\n").select { |x| x =~ /^URL: / }.collect { |x| x[5..-1] }.first
|
217
223
|
when 'git'
|
218
224
|
puts 'git case'
|
219
225
|
repo_info = %x[git remote -v]
|
220
|
-
|
226
|
+
repo_info.split("\n").first[7..-9]
|
221
227
|
else
|
222
|
-
|
228
|
+
'Information not available. Unknown repository type'
|
223
229
|
end
|
224
230
|
end
|
225
231
|
|
@@ -359,7 +365,7 @@ def print_repo_file_diffs(repolatest, repo, fname, user_name, safe_revision)
|
|
359
365
|
end
|
360
366
|
if cmd
|
361
367
|
puts(cmd.join(' '))
|
362
|
-
stdout_and_err_str,
|
368
|
+
stdout_and_err_str, _status = Open3.capture2e(*cmd)
|
363
369
|
puts 'Invalid commit ID in code_safety.yml ' + safe_revision if stdout_and_err_str.start_with?('fatal: Invalid revision range ')
|
364
370
|
puts(stdout_and_err_str)
|
365
371
|
else
|
@@ -367,7 +373,8 @@ def print_repo_file_diffs(repolatest, repo, fname, user_name, safe_revision)
|
|
367
373
|
end
|
368
374
|
|
369
375
|
puts %(To flag the changes to this file as safe, run:)
|
370
|
-
puts
|
376
|
+
puts " #{rake_cmd} audit:safe release=#{repolatest} file=#{fname} reviewed_by=#{user_name}" \
|
377
|
+
' comments=""'
|
371
378
|
puts
|
372
379
|
end
|
373
380
|
|
@@ -397,27 +404,27 @@ def get_release
|
|
397
404
|
end
|
398
405
|
|
399
406
|
def clean_working_copy?
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
407
|
+
case repository_type
|
408
|
+
when 'svn'
|
409
|
+
system('svn status | grep -q [^AMCDG]')
|
410
|
+
when 'git', 'git-svn'
|
411
|
+
system('git diff --quiet HEAD')
|
412
|
+
end
|
406
413
|
end
|
407
414
|
|
408
415
|
def remove_non_existent_files_from_code_safety
|
409
416
|
safety_cfg = YAML.load_file(SAFETY_FILE)
|
410
417
|
file_safety = safety_cfg['file safety']
|
411
|
-
files_no_longer_in_repo = file_safety.keys.reject {|ff| File.file?(ff)}
|
418
|
+
files_no_longer_in_repo = file_safety.keys.reject { |ff| File.file?(ff) }
|
412
419
|
files_no_longer_in_repo.each do |f|
|
413
|
-
puts 'No longer in repository ' + f
|
420
|
+
puts 'No longer in repository ' + f
|
414
421
|
file_safety.delete f
|
415
|
-
end
|
422
|
+
end
|
416
423
|
File.open(SAFETY_FILE, 'w') do |file|
|
417
424
|
# Consistent file diffs, as ruby preserves Hash insertion order since v1.9
|
418
425
|
safety_cfg['file safety'] = Hash[file_safety.sort]
|
419
426
|
YAML.dump(safety_cfg, file) # Save changes before checking latest revisions
|
420
|
-
end
|
427
|
+
end
|
421
428
|
end
|
422
429
|
|
423
430
|
namespace :audit do
|
@@ -440,17 +447,16 @@ files which have changed since they were last verified as safe."
|
|
440
447
|
all_safe = audit_code_safety(max_print, ignore_new, show_diffs, show_in_priority, reviewer)
|
441
448
|
|
442
449
|
unless show_diffs
|
443
|
-
puts
|
450
|
+
puts "To show file diffs, run: #{rake_cmd} audit:code max_print=-1 show_diffs=true"
|
444
451
|
end
|
445
452
|
|
446
453
|
exit(1) unless all_safe
|
447
454
|
end
|
448
455
|
|
449
456
|
desc "Flag a source file as safe.
|
450
|
-
|
451
457
|
Usage:
|
452
|
-
Flag as safe:
|
453
|
-
Needs review:
|
458
|
+
Flag as safe: #{rake_cmd} audit:safe release=revision reviewed_by=usr [comments=...] file=f
|
459
|
+
Needs review: #{rake_cmd} audit:safe release=0 [comments=...] file=f"
|
454
460
|
task(:safe) do
|
455
461
|
release = get_release
|
456
462
|
|
@@ -458,14 +464,14 @@ Usage:
|
|
458
464
|
required_fields << 'reviewed_by' if release # 'Needs review' doesn't need a reviewer
|
459
465
|
missing = required_fields.collect { |f| (f if ENV[f].to_s.empty? || (f == 'reviewed_by' && ENV[f] == 'usr')) }.compact # Avoid accidental missing username
|
460
466
|
unless missing.empty?
|
461
|
-
puts
|
462
|
-
puts
|
467
|
+
puts "Usage: #{rake_cmd} audit:safe release=revision reviewed_by=usr [comments=...] file=f"
|
468
|
+
puts "or, to flag a file for review: #{rake_cmd} audit:safe release=0 [comments=...] file=f"
|
463
469
|
abort("Error: Missing required argument(s): #{missing.join(', ')}")
|
464
470
|
end
|
465
471
|
|
466
472
|
unless release.nil? || release_valid?(release)
|
467
|
-
puts
|
468
|
-
puts
|
473
|
+
puts "Usage: #{rake_cmd} audit:safe release=revision reviewed_by=usr [comments=...] file=f"
|
474
|
+
puts "or, to flag a file for review: #{rake_cmd} audit:safe release=0 [comments=...] file=f"
|
469
475
|
abort("Error: Invalid release: #{ENV['release']}")
|
470
476
|
end
|
471
477
|
|
@@ -495,7 +501,7 @@ Usage:
|
|
495
501
|
rescue SystemExit => ex
|
496
502
|
puts '=============================================================='
|
497
503
|
puts 'Code safety review of some files are not up-to-date; aborting!'
|
498
|
-
puts
|
504
|
+
puts " - to review the files in question, run: #{rake_cmd} audit:code"
|
499
505
|
puts '=============================================================='
|
500
506
|
|
501
507
|
raise ex
|
@@ -505,4 +511,3 @@ end
|
|
505
511
|
|
506
512
|
# Prevent building of un-reviewed gems:
|
507
513
|
task build: :'audit:ensure_safe'
|
508
|
-
|
data/ndr_dev_support.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_dev_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.52.1
|
34
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: 0.
|
40
|
+
version: 0.52.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: parser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +157,7 @@ extensions: []
|
|
157
157
|
extra_rdoc_files: []
|
158
158
|
files:
|
159
159
|
- ".gitignore"
|
160
|
+
- ".hound.yml"
|
160
161
|
- ".rubocop.yml"
|
161
162
|
- ".travis.yml"
|
162
163
|
- CODE_OF_CONDUCT.md
|