Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
Finished first pass on rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Henrich committed Jun 24, 2014
1 parent 82237ec commit b1fa3cf
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 327 deletions.
173 changes: 5 additions & 168 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ Lint/Eval:
Lint/ShadowingOuterLocalVariable:
Enabled: false

#######
# We actually want these off

# Offense count: 2
Lint/UselessSetterCall:
Enabled: false
#######

# Offense count: 2
Style/CaseEquality:
Enabled: false

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Expand All @@ -50,179 +38,28 @@ Style/ClassAndModuleChildren:
Style/ClassLength:
Max: 506

# Offense count: 1
# Cop supports --auto-correct.
Style/CommentIndentation:
Enabled: false

# Offense count: 12
Style/CyclomaticComplexity:
Max: 18

# Offense count: 6
# Cop supports --auto-correct.
Style/DeprecatedHashMethods:
Enabled: false

# Offense count: 17
Style/Documentation:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs.
Style/EmptyLineBetweenDefs:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Style/EmptyLines:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
Style/EmptyLinesAroundBody:
Enabled: false

# Offense count: 8
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Enabled: false

# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/IndentationConsistency:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/IndentationWidth:
Enabled: false

# Offense count: 4
Style/Lambda:
Enabled: false

# Offense count: 11
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Enabled: false
#######
# We actually want these off

# Offense count: 1
# Cop supports --auto-correct.
Style/MethodCallParentheses:
# Offense count: 2
Lint/UselessSetterCall:
Enabled: false

# Offense count: 9
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/Next:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/NilComparison:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IncludeSemanticChanges.
Style/NonNilCheck:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/RedundantSelf:
Enabled: false

# Offense count: 3
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
Enabled: false

# Offense count: 6
# Cop supports --auto-correct.
Style/SpaceAfterComma:
Enabled: false

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Style/SpaceInsideBlockBraces:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
Style/SpaceInsideBrackets:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SpecialGlobalVars:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/TrailingBlankLines:
Enabled: false

# Offense count: 1
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Enabled: false

# Offense count: 11
# Cop supports --auto-correct.
Style/TrailingWhitespace:
Enabled: false

# Offense count: 7
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/VariableName:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/WordArray:
MinSize: 19
#######
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
# THE SOFTWARE.
#

#!/usr/bin/env rake
require 'rspec/core/rake_task'
require 'yard'
require 'rubocop/rake_task'

RuboCop::RakeTask.new

RSpec::Core::RakeTask.new(:spec, :tag) do |spec|
spec.pattern = '.spec/**/*_spec.rb'
Expand Down Expand Up @@ -67,4 +69,4 @@ namespace :doc do
end
end

task default: :unit_tests
task default: [:unit_tests, :rubocop]
2 changes: 0 additions & 2 deletions bin/generate
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# THE SOFTWARE.
#


$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
require 'jenkins_pipeline_builder'
JenkinsPipelineBuilder::CLI::Base.start

12 changes: 6 additions & 6 deletions jenkins_pipeline_builder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Gem::Specification.new do |spec|
spec.version = JenkinsPipelineBuilder::VERSION
spec.authors = ['Igor Moochnick']
spec.email = %w([email protected])
spec.description = %q{This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
automating Job & Pipeline creation from the YAML files checked-in with your application source code}
spec.summary = %q{This gem is will boostrap your Jenkins pipelines}
spec.description = %q(This is a simple and easy-to-use Jenkins Pipeline generator with features focused on
automating Job & Pipeline creation from the YAML files checked-in with your application source code)
spec.summary = %q(This gem is will boostrap your Jenkins pipelines)
spec.homepage = 'https://github.com/IgorShare/jenkins_pipeline_builder'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.files = `git ls-files`.split($RS)
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
spec.require_paths = ['lib']

ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] = 'true'
Expand Down
7 changes: 3 additions & 4 deletions lib/jenkins_pipeline_builder/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def self.build_multijob(params, xml)
xml.exposedSCM job[:exposed_scm] || false
if job[:config]
xml.configs do
if job[:config].has_key? :predefined_build_parameters
if job[:config].key? :predefined_build_parameters
xml.send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') do
xml.properties job[:config][:predefined_build_parameters].join "\n"
end
Expand Down Expand Up @@ -73,13 +73,13 @@ def self.build_environment_vars_injector(params, xml)
end

def self.blocking_downstream(params, xml)
colors = { 'SUCCESS' => { ordinal: 0, color: 'BLUE' },'FAILURE' => { ordinal: 2, color: 'RED' },'UNSTABLE' => { ordinal: 1, color: 'YELLOW' } }
colors = { 'SUCCESS' => { ordinal: 0, color: 'BLUE' }, 'FAILURE' => { ordinal: 2, color: 'RED' }, 'UNSTABLE' => { ordinal: 1, color: 'YELLOW' } }
xml.send('hudson.plugins.parameterizedtrigger.TriggerBuilder', 'plugin' => 'parameterized-trigger') do
xml.configs do
xml.send('hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig') do

xml.configs do
params[:data] = [ { params: '' } ] unless params[:data]
params[:data] = [{ params: '' }] unless params[:data]
params[:data].each do |config|
if config[:params]
xml.send('hudson.plugins.parameterizedtrigger.PredefinedBuildParameters') do
Expand Down Expand Up @@ -170,6 +170,5 @@ def self.start_remote_job(params, xml)
end
end
end

end
end
3 changes: 0 additions & 3 deletions lib/jenkins_pipeline_builder/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
#

require 'thor'
#require "#{File.dirname(__FILE__)}/pipeline.rb"

module JenkinsPipelineBuilder
module CLI
class Base < Thor

class_option :username, aliases: '-u', desc: 'Name of Jenkins user'
class_option :password, aliases: '-p', desc: 'Password of Jenkins user'
class_option :password_base64, aliases: '-b', desc: 'Base 64 encoded password of Jenkins user'
Expand All @@ -35,7 +33,6 @@ class Base < Thor
class_option :creds_file, aliases: '-c', desc: 'Credentials file for communicating with Jenkins server'
class_option :debug, type: :boolean, aliases: '-d', desc: 'Run in debug mode (no Jenkins changes)', default: false


map '-v' => :version

desc 'version', 'Shows current version'
Expand Down
15 changes: 4 additions & 11 deletions lib/jenkins_pipeline_builder/cli/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,10 @@ def self.setup(options)
(options[:password] || options[:password_base64])
creds = options
elsif options[:creds_file]
creds = YAML.load_file(
File.expand_path(options[:creds_file])
#File.expand_path(options[:creds_file], __FILE__)
#options[:creds_file]
)
creds = YAML.load_file(File.expand_path(options[:creds_file]))
elsif File.exist?("#{ENV['HOME']}/.jenkins_api_client/login.yml")
creds = YAML.load_file(
File.expand_path(
"#{ENV['HOME']}/.jenkins_api_client/login.yml", __FILE__
)
File.expand_path("#{ENV['HOME']}/.jenkins_api_client/login.yml", __FILE__)
)
else
msg = 'Credentials are not set. Please pass them as parameters or'
Expand All @@ -62,11 +56,10 @@ def self.setup(options)
exit 1
end

#creds[:log_level] = Logger::DEBUG
client = JenkinsApi::Client.new(creds)
generator = JenkinsPipelineBuilder::Generator.new(client)
generator.debug = options[:debug] #== 'debug'
return generator
generator.debug = options[:debug]
generator
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/cli/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def create(path)
end
end
end
end
end
Loading

0 comments on commit b1fa3cf

Please sign in to comment.