Skip to content

Commit dd4e448

Browse files
authored
Merge pull request #83 from mitre/addRubocop
Run rubocop automatically as part of CI and correct current Rubocop errors
2 parents 6f38441 + f6aeccd commit dd4e448

20 files changed

+390
-270
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
test:
10+
lint:
1111
strategy:
1212
matrix:
1313
platform: [ubuntu-16.04, ubuntu-latest, macos-latest, windows-latest]

.github/workflows/rubocop.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Run rubocop
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- run: git fetch origin +refs/tags/*:refs/tags/*
17+
- name: Install Ruby
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: 2.7
21+
- name: Install and run Rubocop
22+
run: |
23+
bundle install
24+
bundle exec rubocop

.rubocop.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
---
2+
inherit_from: .rubocop_todo.yml
3+
24
AllCops:
5+
NewCops: enable
36
TargetRubyVersion: 2.4
47
Exclude:
58
- Gemfile
69
- Rakefile
710
- 'test/**/*'
811
- 'examples/plugins/train-*/test/**/*'
912
- 'vendor/**/*'
10-
Documentation:
13+
Style/Documentation:
1114
Enabled: false
12-
AlignParameters:
15+
Layout/ParameterAlignment:
1316
Enabled: true
14-
Encoding:
17+
Style/Encoding:
1518
Enabled: false
16-
HashSyntax:
19+
Style/HashSyntax:
1720
Enabled: true
18-
LineLength:
21+
Layout/LineLength:
1922
Enabled: false
20-
EmptyLinesAroundBlockBody:
23+
Layout/EmptyLinesAroundBlockBody:
2124
Enabled: false
22-
MethodLength:
23-
Max: 40
24-
NumericLiterals:
25+
Style/NumericLiterals:
2526
MinDigits: 10
26-
Metrics/CyclomaticComplexity:
27-
Max: 10
28-
Metrics/PerceivedComplexity:
29-
Max: 10
30-
Metrics/AbcSize:
31-
Max: 33
3227
Metrics/ModuleLength:
3328
Enabled: false
3429
Style/PercentLiteralDelimiters:
@@ -42,16 +37,14 @@ Style/PercentLiteralDelimiters:
4237
'%w': '{}'
4338
'%W': ()
4439
'%x': ()
45-
Layout/AlignHash:
40+
Layout/HashAlignment:
4641
Enabled: false
4742
Naming/PredicateName:
4843
Enabled: false
4944
Style/ClassAndModuleChildren:
5045
Enabled: false
5146
Style/ConditionalAssignment:
5247
Enabled: false
53-
Style/BracesAroundHashParameters:
54-
Enabled: false
5548
Style/AndOr:
5649
Enabled: false
5750
Style/Not:
@@ -66,13 +59,13 @@ Style/NegatedIf:
6659
Enabled: false
6760
Style/UnlessElse:
6861
Enabled: false
69-
BlockDelimiters:
62+
Style/BlockDelimiters:
7063
Enabled: false
7164
Layout/SpaceAroundOperators:
7265
Enabled: false
7366
Style/IfUnlessModifier:
7467
Enabled: false
7568
Style/FrozenStringLiteralComment:
7669
Enabled: false
77-
SignalException:
70+
Style/SignalException:
7871
Enabled: false

.rubocop_todo.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2021-03-16 17:26:37 UTC using RuboCop version 1.11.0.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# Configuration parameters: Include.
11+
# Include: **/*.gemspec
12+
Gemspec/RequiredRubyVersion:
13+
Exclude:
14+
- 'heimdall_tools.gemspec'
15+
16+
# Offense count: 1
17+
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
18+
Lint/DuplicateBranch:
19+
Exclude:
20+
- 'lib/heimdall_tools/dbprotect_mapper.rb'
21+
22+
# Offense count: 3
23+
# Configuration parameters: MaximumRangeSize.
24+
Lint/MissingCopEnableDirective:
25+
Exclude:
26+
- 'lib/heimdall_tools/burpsuite_mapper.rb'
27+
- 'lib/heimdall_tools/nessus_mapper.rb'
28+
- 'lib/heimdall_tools/zap_mapper.rb'
29+
30+
# Offense count: 1
31+
Lint/RequireParentheses:
32+
Exclude:
33+
- 'lib/heimdall_tools/sonarqube_mapper.rb'
34+
35+
# Offense count: 1
36+
# Cop supports --auto-correct.
37+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
38+
Lint/UnusedMethodArgument:
39+
Exclude:
40+
- 'lib/heimdall_tools/hdf.rb'
41+
42+
# Offense count: 2
43+
# Configuration parameters: CheckForMethodsWithNoSideEffects.
44+
Lint/Void:
45+
Exclude:
46+
- 'lib/heimdall_tools/aws_config_mapper.rb'
47+
48+
# Offense count: 20
49+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
50+
Metrics/AbcSize:
51+
Max: 56
52+
53+
# Offense count: 4
54+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
55+
# IgnoredMethods: refine
56+
Metrics/BlockLength:
57+
Max: 49
58+
59+
# Offense count: 2
60+
# Configuration parameters: CountBlocks.
61+
Metrics/BlockNesting:
62+
Max: 5
63+
64+
# Offense count: 6
65+
# Configuration parameters: CountComments, CountAsOne.
66+
Metrics/ClassLength:
67+
Max: 171
68+
69+
# Offense count: 7
70+
# Configuration parameters: IgnoredMethods.
71+
Metrics/CyclomaticComplexity:
72+
Max: 17
73+
74+
# Offense count: 32
75+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
76+
Metrics/MethodLength:
77+
Max: 52
78+
79+
# Offense count: 1
80+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
81+
Metrics/ParameterLists:
82+
Max: 18
83+
84+
# Offense count: 6
85+
# Configuration parameters: IgnoredMethods.
86+
Metrics/PerceivedComplexity:
87+
Max: 17
88+
89+
# Offense count: 3
90+
Naming/AccessorMethodName:
91+
Exclude:
92+
- 'lib/heimdall_tools/aws_config_mapper.rb'
93+
- 'lib/heimdall_tools/sonarqube_mapper.rb'
94+
95+
# Offense count: 1
96+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
97+
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
98+
Naming/MethodParameterName:
99+
Exclude:
100+
- 'lib/heimdall_tools/command.rb'
101+
102+
# Offense count: 1
103+
# Configuration parameters: EnforcedStyle, AllowedIdentifiers.
104+
# SupportedStyles: snake_case, camelCase
105+
Naming/VariableName:
106+
Exclude:
107+
- 'lib/heimdall_tools/burpsuite_mapper.rb'
108+
109+
# Offense count: 8
110+
# Configuration parameters: AllowedVariables.
111+
Style/GlobalVars:
112+
Exclude:
113+
- 'lib/heimdall_tools/jfrog_xray_mapper.rb'
114+
- 'lib/heimdall_tools/nessus_mapper.rb'
115+
- 'lib/heimdall_tools/nikto_mapper.rb'
116+
- 'lib/heimdall_tools/snyk_mapper.rb'
117+
118+
# Offense count: 10
119+
# Configuration parameters: AllowedMethods.
120+
# AllowedMethods: respond_to_missing?
121+
Style/OptionalBooleanParameter:
122+
Exclude:
123+
- 'lib/heimdall_tools/aws_config_mapper.rb'
124+
- 'lib/heimdall_tools/burpsuite_mapper.rb'
125+
- 'lib/heimdall_tools/dbprotect_mapper.rb'
126+
- 'lib/heimdall_tools/fortify_mapper.rb'
127+
- 'lib/heimdall_tools/jfrog_xray_mapper.rb'
128+
- 'lib/heimdall_tools/nessus_mapper.rb'
129+
- 'lib/heimdall_tools/netsparker_mapper.rb'
130+
- 'lib/heimdall_tools/nikto_mapper.rb'
131+
- 'lib/heimdall_tools/snyk_mapper.rb'
132+
- 'lib/heimdall_tools/zap_mapper.rb'

heimdall_tools.gemspec

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# coding: utf-8
22

3-
# rubocop:disable Style/GuardClause
4-
53
lib = File.expand_path('lib', __dir__)
64
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
75
begin
@@ -10,9 +8,13 @@ rescue LoadError
108
nil
119
end
1210

13-
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
11+
Gem::Specification.new do |spec|
1412
spec.name = 'heimdall_tools'
15-
spec.version = HeimdallTools::VERSION rescue "0.0.0.1.ENOGVB"
13+
spec.version = begin
14+
HeimdallTools::VERSION
15+
rescue StandardError
16+
'0.0.0.1.ENOGVB'
17+
end
1618
spec.authors = ['Robert Thew', 'Rony Xavier', 'Aaron Lippold']
1719
spec.email = ['rxavier@mitre.org']
1820
spec.summary = 'Convert Forify, Openzap and Sonarqube results to HDF'
@@ -27,15 +29,16 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
2729
spec.require_paths = ['lib']
2830

2931
spec.add_runtime_dependency 'aws-sdk-configservice', '~> 1'
30-
spec.add_runtime_dependency 'nokogiri', '~> 1.10.9'
31-
spec.add_runtime_dependency 'thor', '~> 0.19'
32-
spec.add_runtime_dependency 'json', '~> 2.3'
3332
spec.add_runtime_dependency 'csv', '~> 3.1'
33+
spec.add_runtime_dependency 'git-lite-version-bump', '>= 0.17.2'
3434
spec.add_runtime_dependency 'httparty', '~> 0.18.0'
35+
spec.add_runtime_dependency 'json', '~> 2.3'
36+
spec.add_runtime_dependency 'nokogiri', '~> 1.10.9'
3537
spec.add_runtime_dependency 'openssl', '~> 2.1'
36-
spec.add_runtime_dependency 'git-lite-version-bump', '>= 0.17.2'
38+
spec.add_runtime_dependency 'thor', '~> 0.19'
3739
spec.add_development_dependency 'bundler'
3840
spec.add_development_dependency 'minitest', '~> 5.0'
3941
spec.add_development_dependency 'pry'
4042
spec.add_development_dependency 'rake'
43+
spec.add_development_dependency 'rubocop', '~> 1.11'
4144
end

0 commit comments

Comments
 (0)