Skip to content

Commit 7d5fdb4

Browse files
committed
Additional Rubocop Changes
This change makes additional Rubocop source code updates. It seems wide-spread, but all changes are individually trivial.
1 parent 87b7ef4 commit 7d5fdb4

File tree

112 files changed

+965
-850
lines changed

Some content is hidden

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

112 files changed

+965
-850
lines changed

.idea/dictionaries/bhale.xml

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

.idea/misc.xml

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

.rubocop.yml

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
---
2+
require: rubocop-rspec
3+
24
AllCops:
35
Include:
46
- Rakefile
57
- rakelib/**/*
68
Exclude:
79
- build/**/*
8-
- vendor/**/*
9-
AbcSize:
10-
Max: 18
11-
ClassLength:
10+
Metrics/AbcSize:
11+
Max: 18
12+
Metrics/ClassLength:
1213
Max: 200
13-
CyclomaticComplexity:
14+
Metrics/CyclomaticComplexity:
1415
Max: 10
15-
Documentation:
16+
Metrics/LineLength:
17+
Max: 120
18+
Metrics/MethodLength:
19+
Max: 17
20+
Metrics/ParameterLists:
21+
Max: 6
22+
Metrics/PerceivedComplexity:
23+
Max: 10
24+
RSpec/FilePath:
1625
Enabled: false
17-
EmptyLinesAroundModuleBody:
26+
Style/Documentation:
1827
Enabled: false
19-
EmptyLinesAroundClassBody:
28+
Style/EmptyLinesAroundClassBody:
2029
Enabled: false
21-
MultilineOperationIndentation:
30+
Style/EmptyLinesAroundModuleBody:
2231
Enabled: false
23-
LineLength:
32+
Style/MultilineOperationIndentation:
2433
Enabled: false
25-
MethodLength:
26-
Max: 25
27-
ParameterLists:
28-
Max: 6
29-
PerceivedComplexity:
30-
Max: 10

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ group :development do
66
gem 'redcarpet'
77
gem 'rspec'
88
gem 'rubocop'
9+
gem 'rubocop-rspec'
910
gem 'rubyzip'
1011
gem 'simplecov'
1112
gem 'tee'

Gemfile.lock

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ GEM
3737
powerpack (~> 0.0.6)
3838
rainbow (>= 1.99.1, < 3.0)
3939
ruby-progressbar (~> 1.4)
40+
rubocop-rspec (1.2.1)
4041
ruby-progressbar (1.7.0)
4142
rubyzip (1.1.6)
4243
safe_yaml (1.0.4)
@@ -61,6 +62,7 @@ DEPENDENCIES
6162
redcarpet
6263
rspec
6364
rubocop
65+
rubocop-rspec
6466
rubyzip
6567
simplecov
6668
tee

Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RSpec::Core::RakeTask.new
2121
CLEAN.include 'coverage'
2222

2323
require 'rubocop/rake_task'
24-
RuboCop::RakeTask.new
24+
RuboCop::RakeTask.new { |t| t.requires << 'rubocop-rspec' }
2525

2626
require 'yard'
2727
YARD::Rake::YardocTask.new
@@ -39,7 +39,7 @@ require 'rakelib/stage_buildpack_task'
3939
require 'rakelib/package_task'
4040
Package::DependencyCacheTask.new
4141
Package::StageBuildpackTask.new(Dir['bin/**/*', 'config/**/*', 'lib/**/*', 'resources/**/*']
42-
.reject { |f| File.directory? f })
42+
.reject { |f| File.directory? f })
4343
Package::PackageTask.new
4444

4545
task default: %w(rubocop check_api_doc spec)

java-buildpack.iml

+2-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, rbenv: 1.9.3-p551) [gem]" level="application" />
272272
<orderEntry type="library" scope="PROVIDED" name="ast (v2.0.0, rbenv: 1.9.3-p551) [gem]" level="application" />
273273
<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" />
274+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.8, rbenv: 1.9.3-p551) [gem]" level="application" />
275275
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.4.3, rbenv: 1.9.3-p551) [gem]" level="application" />
276276
<orderEntry type="library" scope="PROVIDED" name="crack (v0.4.2, rbenv: 1.9.3-p551) [gem]" level="application" />
277277
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 1.9.3-p551) [gem]" level="application" />
@@ -288,6 +288,7 @@
288288
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.1.3, rbenv: 1.9.3-p551) [gem]" level="application" />
289289
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.1.2, rbenv: 1.9.3-p551) [gem]" level="application" />
290290
<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="rubocop-rspec (v1.2.1, rbenv: 1.9.3-p551) [gem]" level="application" />
291292
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.7.0, rbenv: 1.9.3-p551) [gem]" level="application" />
292293
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v1.1.6, rbenv: 1.9.3-p551) [gem]" level="application" />
293294
<orderEntry type="library" scope="PROVIDED" name="safe_yaml (v1.0.4, rbenv: 1.9.3-p551) [gem]" level="application" />

lib/java_buildpack/buildpack.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ 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-
instantiate_components(additional_libraries, app_dir, application, immutable_java_home, java_opts, mutable_java_home)
111+
instantiate_components(additional_libraries, app_dir, application, immutable_java_home, java_opts,
112+
mutable_java_home)
112113
end
113114

114-
def instantiate_components(additional_libraries, app_dir, application, immutable_java_home, java_opts, mutable_java_home)
115-
components = JavaBuildpack::Util::ConfigurationUtils.load 'components'
115+
def instantiate_components(additional_libraries, app_dir, application, immutable_java_home, java_opts,
116+
mutable_java_home)
117+
components = JavaBuildpack::Util::ConfigurationUtils.load 'components'
116118
@jres = instantiate(components['jres'], additional_libraries, application, mutable_java_home, java_opts,
117119
app_dir)
118120
@frameworks = instantiate(components['frameworks'], additional_libraries, application, immutable_java_home,

lib/java_buildpack/buildpack_version.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def to_hash
7474
# Creates a string representation of the version. The string representation looks like the following:
7575
# +[[<VERSION> [(offline)] | ] <REMOTE>#<HASH>] | [unknown]+. Some examples:
7676
#
77-
# +2.1.2 (offline) | https://github.com/cloudfoundry/java-buildpack.git#12345+ (custom version number, offline buildpack)
77+
# +2.1.2 (offline) | https://github.com/cloudfoundry/java-buildpack.git#12345+ (custom version number, offline
78+
# buildpack)
7879
# +abcde | https://github.com/cloudfoundry/java-buildpack.git#abcde+ (default version number, online buildpack)
7980
# +https://github.com/cloudfoundry/java-buildpack#12345+ (cloned buildpack)
8081
# +unknown+ (un-packaged, un-cloned)

lib/java_buildpack/component/base_component.rb

+11-7
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ def compile
6262
fail "Method 'compile' must be defined"
6363
end
6464

65-
# Modifies the application's runtime configuration. The component is expected to transform members of the +context+
66-
# (e.g. +@java_home+, +@java_opts+, etc.) in whatever way is necessary to support the function of the component.
65+
# Modifies the application's runtime configuration. The component is expected to transform members of the
66+
# +context+ # (e.g. +@java_home+, +@java_opts+, etc.) in whatever way is necessary to support the function of the
67+
# component.
6768
#
6869
# Container components are also expected to create the command required to run the application. These components
6970
# are expected to read the +context+ values and take them into account when creating the command.
@@ -76,8 +77,8 @@ def release
7677

7778
protected
7879

79-
# Downloads an item with the given name and version from the given URI, then yields the resultant file to the given
80-
# block.
80+
# Downloads an item with the given name and version from the given URI, then yields the resultant file to the
81+
# given # block.
8182
#
8283
# @param [JavaBuildpack::Util::TokenizedVersion] version
8384
# @param [String] uri
@@ -112,7 +113,8 @@ def download_jar(version, uri, jar_name, target_directory = @droplet.sandbox, na
112113
#
113114
# @param [String] version the version of the download
114115
# @param [String] uri the uri of the download
115-
# @param [Pathname] target_directory the directory to expand the TAR file to. Defaults to the component's sandbox.
116+
# @param [Pathname] target_directory the directory to expand the TAR file to. Defaults to the component's
117+
# sandbox.
116118
# @param [String] name an optional name for the download and expansion. Defaults to +@component_name+.
117119
# @return [Void]
118120
def download_tar(version, uri, target_directory = @droplet.sandbox, name = @component_name)
@@ -127,10 +129,12 @@ def download_tar(version, uri, target_directory = @droplet.sandbox, name = @comp
127129
# Downloads a given ZIP file and expands it.
128130
#
129131
# @param [Boolean] strip_top_level whether to strip the top-level directory when expanding. Defaults to +true+.
130-
# @param [Pathname] target_directory the directory to expand the ZIP file to. Defaults to the component's sandbox.
132+
# @param [Pathname] target_directory the directory to expand the ZIP file to. Defaults to the component's
133+
# sandbox.
131134
# @param [String] name an optional name for the download. Defaults to +@component_name+.
132135
# @return [Void]
133-
def download_zip(version, uri, strip_top_level = true, target_directory = @droplet.sandbox, name = @component_name)
136+
def download_zip(version, uri, strip_top_level = true, target_directory = @droplet.sandbox,
137+
name = @component_name)
134138
download(version, uri, name) do |file|
135139
with_timing "Expanding #{name} to #{target_directory.relative_path_from(@droplet.root)}" do
136140
if strip_top_level

lib/java_buildpack/component/droplet.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ class Droplet
6060

6161
# Creates a new instance of the droplet abstraction
6262
#
63-
# @param [AdditionalLibraries] additional_libraries the shared +AdditionalLibraries+ instance for all components
63+
# @param [AdditionalLibraries] additional_libraries the shared +AdditionalLibraries+ instance for all
64+
# components
6465
# @param [String] component_id the id of the component that will use this +Droplet+
6566
# @param [ImmutableJavaHome, MutableJavaHome] java_home the shared +JavaHome+ instance for all components. If the
66-
# component using this instance is a jre, then this should be
67-
# an instance of +MutableJavaHome+. Otherwise it should be an
68-
# instance of +ImmutableJavaHome+.
67+
# component using this instance is a jre, then this should
68+
# be an instance of +MutableJavaHome+. Otherwise it should
69+
# be an instance of +ImmutableJavaHome+.
6970
# @param [JavaOpts] java_opts the shared +JavaOpts+ instance for all components
7071
# @param [Pathname] root the root of the droplet
7172
def initialize(additional_libraries, component_id, java_home, java_opts, root)
@@ -79,9 +80,8 @@ def initialize(additional_libraries, component_id, java_home, java_opts, root)
7980
sandbox_root = buildpack_root + component_id
8081

8182
@sandbox = JavaBuildpack::Util::FilteringPathname.new(sandbox_root, ->(path) { in?(path, sandbox_root) }, true)
82-
@root = JavaBuildpack::Util::FilteringPathname.new(root,
83-
->(path) { !in?(path, buildpack_root) || in?(path, @sandbox) },
84-
true)
83+
@root = JavaBuildpack::Util::FilteringPathname.new(
84+
root, ->(path) { !in?(path, buildpack_root) || in?(path, @sandbox) }, true)
8585
end
8686

8787
# Copy resources from a components resources directory to a directory

lib/java_buildpack/component/java_opts.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def add_system_property(key, value)
5555
self
5656
end
5757

58-
# Adds an option to the +JAVA_OPTS+. Nothing is prepended to the key. If the value is a +Pathname+, then prepends
59-
# +$PWD+ to the path (relative to the droplet root) to ensure that the path is always accurate. Otherwise, uses
60-
# the value as-is.
58+
# Adds an option to the +JAVA_OPTS+. Nothing is prepended to the key. If the value is a +Pathname+, then
59+
# prepends +$PWD+ to the path (relative to the droplet root) to ensure that the path is always accurate.
60+
# Otherwise, uses the value as-is.
6161
#
6262
# @param [String] key the key of the option
6363
# @param [Pathname, String] value the value of the system property

lib/java_buildpack/component/versioned_dependency_component.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def download_jar(jar_name = jar_name, target_directory = @droplet.sandbox, name
7171

7272
# Downloads a given TAR file and expands it.
7373
#
74-
# @param [Pathname] target_directory the directory to expand the TAR file to. Defaults to the component's sandbox.
74+
# @param [Pathname] target_directory the directory to expand the TAR file to. Defaults to the component's
75+
# sandbox.
7576
# @param [String] name an optional name for the download and expansion. Defaults to +@component_name+.
7677
# @return [Void]
7778
def download_tar(target_directory = @droplet.sandbox, name = @component_name)
@@ -81,7 +82,8 @@ def download_tar(target_directory = @droplet.sandbox, name = @component_name)
8182
# Downloads a given ZIP file and expands it.
8283
#
8384
# @param [Boolean] strip_top_level whether to strip the top-level directory when expanding. Defaults to +true+.
84-
# @param [Pathname] target_directory the directory to expand the ZIP file to. Defaults to the component's sandbox.
85+
# @param [Pathname] target_directory the directory to expand the ZIP file to. Defaults to the component's
86+
# sandbox.
8587
# @param [String] name an optional name for the download. Defaults to +@component_name+.
8688
# @return [Void]
8789
def download_zip(strip_top_level = true, target_directory = @droplet.sandbox, name = @component_name)

lib/java_buildpack/container/java_main.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
module JavaBuildpack
2323
module Container
2424

25-
# Encapsulates the detect, compile, and release functionality for applications running a simple Java +main()+ method.
26-
# This isn't a _container_ in the traditional sense, but contains the functionality to manage the lifecycle of Java
27-
# +main()+ applications.
25+
# Encapsulates the detect, compile, and release functionality for applications running a simple Java +main()+
26+
# method. This isn't a _container_ in the traditional sense, but contains the functionality to manage the lifecycle
27+
# of Java +main()+ applications.
2828
class JavaMain < JavaBuildpack::Component::BaseComponent
2929

3030
# (see JavaBuildpack::Component::BaseComponent#detect)

lib/java_buildpack/container/spring_boot_cli.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ def supports?
6767
private
6868

6969
def relative_groovy_files
70-
JavaBuildpack::Util::GroovyUtils.groovy_files(@application).map { |gf| gf.relative_path_from(@application.root) }
70+
JavaBuildpack::Util::GroovyUtils.groovy_files(@application).map do |gf|
71+
gf.relative_path_from(@application.root)
72+
end
7173
end
7274

7375
def no_main_method(groovy_files)
74-
none?(groovy_files) { |file| JavaBuildpack::Util::GroovyUtils.main_method? file } # note that this will scan comments
76+
none?(groovy_files) { |file| JavaBuildpack::Util::GroovyUtils.main_method? file }
7577
end
7678

7779
def no_shebang(groovy_files)

lib/java_buildpack/framework/java_opts.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def detect
3333
# (see JavaBuildpack::Component::BaseComponent#compile)
3434
def compile
3535
parsed_java_opts.each do |option|
36-
fail "Java option '#{option}' configures a memory region. Use JRE configuration for this instead." if memory_option? option
36+
if memory_option? option
37+
fail "Java option '#{option}' configures a memory region. Use JRE configuration for this instead."
38+
end
3739
end
3840
end
3941

lib/java_buildpack/framework/play_framework_auto_reconfiguration.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
module JavaBuildpack
2222
module Framework
2323

24-
# Encapsulates the functionality for enabling cloud auto-reconfiguration in Play applications. Note that Spring auto-
25-
# reconfiguration is covered by the SpringAutoReconfiguration framework. The reconfiguration performed here is to
26-
# override Play application configuration to bind a Play application to cloud resources.
24+
# Encapsulates the functionality for enabling cloud auto-reconfiguration in Play applications. Note that Spring
25+
# auto- reconfiguration is covered by the SpringAutoReconfiguration framework. The reconfiguration performed here is
26+
# to override Play application configuration to bind a Play application to cloud resources.
2727
class PlayFrameworkAutoReconfiguration < JavaBuildpack::Component::VersionedDependencyComponent
2828

2929
# (see JavaBuildpack::Component::BaseComponent#compile)

lib/java_buildpack/framework/spring_auto_reconfiguration/web_xml_modifier.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ def to_s
8080
private_constant :CONTEXT_INITIALIZER_CLASSES, :CONTEXT_LOADER_LISTENER, :DISPATCHER_SERVLET
8181

8282
def augment(root, param_type)
83-
classes_string = xpath(root, "#{param_type}[param-name[contains(text(), '#{CONTEXT_INITIALIZER_CLASSES}')]]/param-value/text()").first
83+
classes_string = xpath(root, "#{param_type}[param-name[contains(text(),
84+
'#{CONTEXT_INITIALIZER_CLASSES}')]]/param-value/text()").first
8485
classes_string = create_param(root, param_type, CONTEXT_INITIALIZER_CLASSES, '') unless classes_string
8586

8687
classes = classes_string.value.strip.split(/[,;\s]+/)
8788
classes = classes.concat CONTEXT_INITIALIZER_ADDITIONAL
8889

89-
classes_string.value = classes.join(',') # rubocop:disable UselessSetterCall
90+
classes_string.value = classes.join(',') # rubocop:disable Lint/UselessSetterCall
9091
end
9192

9293
def context_loader_listener?

0 commit comments

Comments
 (0)