Skip to content

Commit 87b7ef4

Browse files
author
Christopher Frost
committed
Update dependencies and fix Rubocop issues
This commit updates the Ruby/Gem dependencies and then the code as required to pass the new rubocop cops. EmptyLinesAroundBody has been split in to EmptyLinesAroundModuleBody and EmptyLinesAroundClassBody. An AbcSize metric has been introduced and the default overriden to 18, setting this any lower causes far too many invasive refactorings where they arn't required. IntelliJ code formatting settings are also in line with the new cops. [#83541054]
1 parent abefeea commit 87b7ef4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+262
-230
lines changed

.idea/codeStyleSettings.xml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.rubocop.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ AllCops:
66
Exclude:
77
- build/**/*
88
- vendor/**/*
9+
AbcSize:
10+
Max: 18
911
ClassLength:
1012
Max: 200
1113
CyclomaticComplexity:
1214
Max: 10
1315
Documentation:
1416
Enabled: false
15-
EmptyLinesAroundBody:
17+
EmptyLinesAroundModuleBody:
18+
Enabled: false
19+
EmptyLinesAroundClassBody:
20+
Enabled: false
21+
MultilineOperationIndentation:
1622
Enabled: false
1723
LineLength:
1824
Enabled: false

Gemfile.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ GEM
55
ast (2.0.0)
66
astrolabe (1.3.0)
77
parser (>= 2.2.0.pre.3, < 3.0)
8-
codeclimate-test-reporter (0.4.1)
8+
codeclimate-test-reporter (0.4.3)
99
simplecov (>= 0.7.1, < 1.0.0)
1010
crack (0.4.2)
1111
safe_yaml (~> 1.0.0)
1212
diff-lcs (1.2.5)
1313
docile (1.1.5)
1414
multi_json (1.10.1)
15-
parser (2.2.0.pre.6)
15+
parser (2.2.0.pre.8)
1616
ast (>= 1.1, < 3.0)
1717
slop (~> 3.4, >= 3.4.5)
1818
powerpack (0.0.9)
1919
rainbow (2.0.0)
20-
rake (10.3.2)
21-
redcarpet (3.2.0)
20+
rake (10.4.2)
21+
redcarpet (3.2.1)
2222
rspec (3.1.0)
2323
rspec-core (~> 3.1.0)
2424
rspec-expectations (~> 3.1.0)
@@ -31,13 +31,13 @@ GEM
3131
rspec-mocks (3.1.3)
3232
rspec-support (~> 3.1.0)
3333
rspec-support (3.1.2)
34-
rubocop (0.26.1)
34+
rubocop (0.27.1)
3535
astrolabe (~> 1.3)
36-
parser (>= 2.2.0.pre.4, < 3.0)
36+
parser (>= 2.2.0.pre.7, < 3.0)
3737
powerpack (~> 0.0.6)
3838
rainbow (>= 1.99.1, < 3.0)
3939
ruby-progressbar (~> 1.4)
40-
ruby-progressbar (1.6.0)
40+
ruby-progressbar (1.7.0)
4141
rubyzip (1.1.6)
4242
safe_yaml (1.0.4)
4343
simplecov (0.9.1)
@@ -47,7 +47,7 @@ GEM
4747
simplecov-html (0.8.0)
4848
slop (3.6.0)
4949
tee (1.0.0)
50-
webmock (1.20.0)
50+
webmock (1.20.4)
5151
addressable (>= 2.3.6)
5252
crack (>= 0.3.2)
5353
yard (0.8.7.6)

java-buildpack.iml

+30-30
Original file line numberDiff line numberDiff line change
@@ -266,37 +266,37 @@
266266
<excludeFolder url="file://$MODULE_DIR$/coverage" />
267267
<excludeFolder url="file://$MODULE_DIR$/doc" />
268268
</content>
269-
<orderEntry type="jdk" jdkName="ruby-1.9.3-p551" jdkType="RUBY_SDK" />
269+
<orderEntry type="jdk" jdkName="rbenv: 1.9.3-p551" jdkType="RUBY_SDK" />
270270
<orderEntry type="sourceFolder" forTests="false" />
271-
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, ruby-1.9.3-p551) [gem]" level="application" />
272-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.0.0, ruby-1.9.3-p551) [gem]" level="application" />
273-
<orderEntry type="library" scope="PROVIDED" name="astrolabe (v1.3.0, ruby-1.9.3-p551) [gem]" level="application" />
274-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.6, ruby-1.9.3-p551) [gem]" level="application" />
275-
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.4.1, ruby-1.9.3-p551) [gem]" level="application" />
276-
<orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, ruby-1.9.3-p551) [gem]" level="application" />
277-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, ruby-1.9.3-p551) [gem]" level="application" />
278-
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, ruby-1.9.3-p551) [gem]" level="application" />
279-
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.10.1, ruby-1.9.3-p551) [gem]" level="application" />
280-
<orderEntry type="library" scope="PROVIDED" name="parser (v2.2.0.pre.6, ruby-1.9.3-p551) [gem]" level="application" />
281-
<orderEntry type="library" scope="PROVIDED" name="powerpack (v0.0.9, ruby-1.9.3-p551) [gem]" level="application" />
282-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v2.0.0, ruby-1.9.3-p551) [gem]" level="application" />
283-
<orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, ruby-1.9.3-p551) [gem]" level="application" />
284-
<orderEntry type="library" scope="PROVIDED" name="redcarpet (v3.2.0, ruby-1.9.3-p551) [gem]" level="application" />
285-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.1.0, ruby-1.9.3-p551) [gem]" level="application" />
286-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.1.7, ruby-1.9.3-p551) [gem]" level="application" />
287-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.1.2, ruby-1.9.3-p551) [gem]" level="application" />
288-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.1.3, ruby-1.9.3-p551) [gem]" level="application" />
289-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.1.2, ruby-1.9.3-p551) [gem]" level="application" />
290-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.26.1, ruby-1.9.3-p551) [gem]" level="application" />
291-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.6.0, ruby-1.9.3-p551) [gem]" level="application" />
292-
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v1.1.6, ruby-1.9.3-p551) [gem]" level="application" />
293-
<orderEntry type="library" scope="PROVIDED" name="safe_yaml (v1.0.4, ruby-1.9.3-p551) [gem]" level="application" />
294-
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.9.1, ruby-1.9.3-p551) [gem]" level="application" />
295-
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.8.0, ruby-1.9.3-p551) [gem]" level="application" />
296-
<orderEntry type="library" scope="PROVIDED" name="slop (v3.6.0, ruby-1.9.3-p551) [gem]" level="application" />
297-
<orderEntry type="library" scope="PROVIDED" name="tee (v1.0.0, ruby-1.9.3-p551) [gem]" level="application" />
298-
<orderEntry type="library" scope="PROVIDED" name="webmock (v1.20.0, ruby-1.9.3-p551) [gem]" level="application" />
299-
<orderEntry type="library" scope="PROVIDED" name="yard (v0.8.7.6, ruby-1.9.3-p551) [gem]" level="application" />
271+
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, rbenv: 1.9.3-p551) [gem]" level="application" />
272+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.0.0, rbenv: 1.9.3-p551) [gem]" level="application" />
273+
<orderEntry type="library" scope="PROVIDED" name="astrolabe (v1.3.0, rbenv: 1.9.3-p551) [gem]" level="application" />
274+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.7, rbenv: 1.9.3-p551) [gem]" level="application" />
275+
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.4.3, rbenv: 1.9.3-p551) [gem]" level="application" />
276+
<orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, rbenv: 1.9.3-p551) [gem]" level="application" />
277+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 1.9.3-p551) [gem]" level="application" />
278+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.5, rbenv: 1.9.3-p551) [gem]" level="application" />
279+
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.10.1, rbenv: 1.9.3-p551) [gem]" level="application" />
280+
<orderEntry type="library" scope="PROVIDED" name="parser (v2.2.0.pre.8, rbenv: 1.9.3-p551) [gem]" level="application" />
281+
<orderEntry type="library" scope="PROVIDED" name="powerpack (v0.0.9, rbenv: 1.9.3-p551) [gem]" level="application" />
282+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v2.0.0, rbenv: 1.9.3-p551) [gem]" level="application" />
283+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, rbenv: 1.9.3-p551) [gem]" level="application" />
284+
<orderEntry type="library" scope="PROVIDED" name="redcarpet (v3.2.1, rbenv: 1.9.3-p551) [gem]" level="application" />
285+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.1.0, rbenv: 1.9.3-p551) [gem]" level="application" />
286+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.1.7, rbenv: 1.9.3-p551) [gem]" level="application" />
287+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.1.2, rbenv: 1.9.3-p551) [gem]" level="application" />
288+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.1.3, rbenv: 1.9.3-p551) [gem]" level="application" />
289+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.1.2, rbenv: 1.9.3-p551) [gem]" level="application" />
290+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.27.1, rbenv: 1.9.3-p551) [gem]" level="application" />
291+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.7.0, rbenv: 1.9.3-p551) [gem]" level="application" />
292+
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v1.1.6, rbenv: 1.9.3-p551) [gem]" level="application" />
293+
<orderEntry type="library" scope="PROVIDED" name="safe_yaml (v1.0.4, rbenv: 1.9.3-p551) [gem]" level="application" />
294+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.9.1, rbenv: 1.9.3-p551) [gem]" level="application" />
295+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.8.0, rbenv: 1.9.3-p551) [gem]" level="application" />
296+
<orderEntry type="library" scope="PROVIDED" name="slop (v3.6.0, rbenv: 1.9.3-p551) [gem]" level="application" />
297+
<orderEntry type="library" scope="PROVIDED" name="tee (v1.0.0, rbenv: 1.9.3-p551) [gem]" level="application" />
298+
<orderEntry type="library" scope="PROVIDED" name="webmock (v1.20.4, rbenv: 1.9.3-p551) [gem]" level="application" />
299+
<orderEntry type="library" scope="PROVIDED" name="yard (v0.8.7.6, rbenv: 1.9.3-p551) [gem]" level="application" />
300300
</component>
301301
<component name="RModuleSettingsStorage">
302302
<LOAD_PATH number="4" string0="$MODULE_DIR$/lib" string1="$MODULE_DIR$/spec" string2="$MODULE_DIR$/bin" string3="$MODULE_DIR$/spec/bin" />

lib/java_buildpack/buildpack.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ def initialize(app_dir, application)
108108
immutable_java_home = Component::ImmutableJavaHome.new mutable_java_home, app_dir
109109
java_opts = Component::JavaOpts.new app_dir
110110

111-
components = JavaBuildpack::Util::ConfigurationUtils.load 'components'
111+
instantiate_components(additional_libraries, app_dir, application, immutable_java_home, java_opts, mutable_java_home)
112+
end
112113

114+
def instantiate_components(additional_libraries, app_dir, application, immutable_java_home, java_opts, mutable_java_home)
115+
components = JavaBuildpack::Util::ConfigurationUtils.load 'components'
113116
@jres = instantiate(components['jres'], additional_libraries, application, mutable_java_home, java_opts,
114117
app_dir)
115118
@frameworks = instantiate(components['frameworks'], additional_libraries, application, immutable_java_home,
@@ -214,7 +217,5 @@ def handle_error(e, message)
214217
end
215218

216219
end
217-
218220
end
219-
220221
end

lib/java_buildpack/container/dist_zip.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DistZip < JavaBuildpack::Container::DistZipLike
3232
# @param [Hash] context a collection of utilities used the component
3333
def initialize(context)
3434
super(context)
35-
@ratpack_utils = JavaBuildpack::Util::RatpackUtils.new
35+
@ratpack_utils = JavaBuildpack::Util::RatpackUtils.new
3636
@spring_boot_utils = JavaBuildpack::Util::SpringBootUtils.new
3737
end
3838

@@ -49,8 +49,8 @@ def supports?
4949
start_script(root).exist? &&
5050
jars? &&
5151
!@ratpack_utils.is?(@application) &&
52-
!@spring_boot_utils.is?(@application) &&
53-
!JavaBuildpack::Util::Play::Factory.create(@droplet)
52+
!@spring_boot_utils.is?(@application) &&
53+
!JavaBuildpack::Util::Play::Factory.create(@droplet)
5454
end
5555

5656
private

lib/java_buildpack/container/groovy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Groovy < JavaBuildpack::Component::VersionedDependencyComponent
3838
#
3939
# @param [Hash] context a collection of utilities used the component
4040
def initialize(context)
41-
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger Groovy
41+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger Groovy
4242
@ratpack_utils = JavaBuildpack::Util::RatpackUtils.new
4343
super(context) { |candidate_version| candidate_version.check_size(3) }
4444
end

lib/java_buildpack/container/java_main.rb

+12-8
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,7 @@ def release
4141
@droplet.additional_libraries.insert 0, @application.root
4242
manifest_class_path.each { |path| @droplet.additional_libraries << path }
4343

44-
[
45-
port,
46-
"#{@droplet.java_home.root}/bin/java",
47-
@droplet.additional_libraries.as_classpath,
48-
@droplet.java_opts.join(' '),
49-
main_class,
50-
arguments
51-
].flatten.compact.join(' ')
44+
release_text
5245
end
5346

5447
private
@@ -59,6 +52,17 @@ def release
5952

6053
private_constant :ARGUMENTS_PROPERTY, :CLASS_PATH_PROPERTY
6154

55+
def release_text
56+
[
57+
port,
58+
"#{@droplet.java_home.root}/bin/java",
59+
@droplet.additional_libraries.as_classpath,
60+
@droplet.java_opts.join(' '),
61+
main_class,
62+
arguments
63+
].flatten.compact.join(' ')
64+
end
65+
6266
def arguments
6367
@configuration[ARGUMENTS_PROPERTY]
6468
end

lib/java_buildpack/framework/app_dynamics_agent.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ def release
3636
java_opts = @droplet.java_opts
3737

3838
java_opts
39-
.add_javaagent(@droplet.sandbox + 'javaagent.jar')
40-
.add_system_property('appdynamics.agent.applicationName', "'#{application_name}'")
41-
.add_system_property('appdynamics.agent.tierName', "'#{tier_name(credentials)}'")
42-
.add_system_property('appdynamics.agent.nodeName',
43-
"$(expr \"$VCAP_APPLICATION\" : '.*instance_index[\": ]*\\([[:digit:]]*\\).*')")
39+
.add_javaagent(@droplet.sandbox + 'javaagent.jar')
40+
.add_system_property('appdynamics.agent.applicationName', "'#{application_name}'")
41+
.add_system_property('appdynamics.agent.tierName', "'#{tier_name(credentials)}'")
42+
.add_system_property('appdynamics.agent.nodeName',
43+
"$(expr \"$VCAP_APPLICATION\" : '.*instance_index[\": ]*\\([[:digit:]]*\\).*')")
4444

4545
account_access_key(java_opts, credentials)
4646
account_name(java_opts, credentials)

lib/java_buildpack/framework/new_relic_agent.rb

+10-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def compile
3434
# (see JavaBuildpack::Component::BaseComponent#release)
3535
def release
3636
@droplet.java_opts
37-
.add_javaagent(@droplet.sandbox + jar_name)
38-
.add_system_property('newrelic.home', @droplet.sandbox)
39-
.add_system_property('newrelic.config.license_key', license_key)
40-
.add_system_property('newrelic.config.app_name', "'#{application_name}'")
41-
.add_system_property('newrelic.config.log_file_path', logs_dir)
42-
@droplet.java_opts.add_system_property('newrelic.enable.java.8', 'true') if @droplet.java_home.version[1] == '8'
37+
.add_javaagent(@droplet.sandbox + jar_name)
38+
.add_system_property('newrelic.home', @droplet.sandbox)
39+
.add_system_property('newrelic.config.license_key', license_key)
40+
.add_system_property('newrelic.config.app_name', "'#{application_name}'")
41+
.add_system_property('newrelic.config.log_file_path', logs_dir)
42+
@droplet.java_opts.add_system_property('newrelic.enable.java.8', 'true') if java_8?
4343
end
4444

4545
protected
@@ -55,6 +55,10 @@ def supports?
5555

5656
private_constant :FILTER
5757

58+
def java_8?
59+
@droplet.java_home.version[1] == '8'
60+
end
61+
5862
def application_name
5963
@application.details['application_name']
6064
end

lib/java_buildpack/framework/spring_insight.rb

+14-15
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def compile
5151
# (see JavaBuildpack::Component::BaseComponent#release)
5252
def release
5353
@droplet.java_opts
54-
.add_javaagent(weaver_jar)
55-
.add_system_property('insight.base', insight_directory)
56-
.add_system_property('insight.logs', logs_directory)
57-
.add_system_property('aspectj.overweaving', true)
58-
.add_system_property('org.aspectj.tracing.factory', 'default')
59-
.add_system_property('insight.transport.type', 'HTTP')
54+
.add_javaagent(weaver_jar)
55+
.add_system_property('insight.base', insight_directory)
56+
.add_system_property('insight.logs', logs_directory)
57+
.add_system_property('aspectj.overweaving', true)
58+
.add_system_property('org.aspectj.tracing.factory', 'default')
59+
.add_system_property('insight.transport.type', 'HTTP')
6060

6161
add_agent_configuration
6262
end
@@ -81,14 +81,14 @@ def id(version)
8181

8282
def add_agent_configuration
8383
@droplet.java_opts
84-
.add_system_property('agent.http.protocol', 'http')
85-
.add_system_property('agent.http.host', URI(@uri).host)
86-
.add_system_property('agent.http.port', 80)
87-
.add_system_property('agent.http.context.path', 'insight')
88-
.add_system_property('agent.http.username', @agent_id)
89-
.add_system_property('agent.http.password', @agent_pass)
90-
.add_system_property('agent.http.send.json', false)
91-
.add_system_property('agent.http.use.proxy', false)
84+
.add_system_property('agent.http.protocol', 'http')
85+
.add_system_property('agent.http.host', URI(@uri).host)
86+
.add_system_property('agent.http.port', 80)
87+
.add_system_property('agent.http.context.path', 'insight')
88+
.add_system_property('agent.http.username', @agent_id)
89+
.add_system_property('agent.http.password', @agent_pass)
90+
.add_system_property('agent.http.send.json', false)
91+
.add_system_property('agent.http.use.proxy', false)
9292
end
9393

9494
def expand(file)
@@ -200,6 +200,5 @@ def weaver_jar
200200
end
201201

202202
end
203-
204203
end
205204
end

lib/java_buildpack/jre/memory/memory_size.rb

+17-13
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,7 @@ def initialize(size)
3636
fail "Invalid memory size '#{size}'" unless integer? v
3737
v = size.to_i
3838

39-
# Store the number of bytes.
40-
case unit
41-
when 'b', 'B'
42-
@bytes = v
43-
when 'k', 'K'
44-
@bytes = v * KILO
45-
when 'm', 'M'
46-
@bytes = KILO * KILO * v
47-
when 'g', 'G'
48-
@bytes = KILO * KILO * KILO * v
49-
else
50-
fail "Invalid unit '#{unit}' in memory size '#{size}'"
51-
end
39+
store_bytes unit, v, size
5240
end
5341
end
5442

@@ -138,6 +126,22 @@ def /(other)
138126

139127
private_constant :KILO
140128

129+
def store_bytes(unit, v, size)
130+
# Store the number of bytes.
131+
case unit
132+
when 'b', 'B'
133+
@bytes = v
134+
when 'k', 'K'
135+
@bytes = v * KILO
136+
when 'm', 'M'
137+
@bytes = KILO * KILO * v
138+
when 'g', 'G'
139+
@bytes = KILO * KILO * KILO * v
140+
else
141+
fail "Invalid unit '#{unit}' in memory size '#{size}'"
142+
end
143+
end
144+
141145
def memory_size_operation(other)
142146
fail "Invalid parameter: instance of #{other.class} is not a MemorySize" unless other.is_a? MemorySize
143147
from_numeric(yield @bytes, other.bytes)

0 commit comments

Comments
 (0)