Showing 76 of 76 total issues
Method get_build_params
has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring. Open
def get_build_params(job_name)
@logger.info "Obtaining the build params of '#{job_name}'"
xml = get_config(job_name)
n_xml = Nokogiri::XML(xml)
params = n_xml.xpath("//parameterDefinitions").first
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File job.rb
has 1112 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'jenkins_api_client/urihelper'
module JenkinsApi
class Client
# This class communicates with the Jenkins "/job" API to obtain details
Method get_build_id_from_queue
has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring. Open
def get_build_id_from_queue(response, expected_build_id, opts)
# If we get this far the API hasn't detected an error response (it would raise Exception)
# So no need to check response code
# Obtain the queue ID from the location
# header and wait till the build is moved to one of the executors and a
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class Job
has 78 methods (exceeds 20 allowed). Consider refactoring. Open
class Job
include JenkinsApi::UriHelper
# Version that jenkins started to include queued build info in build response
JENKINS_QUEUE_ID_SUPPORT_VERSION = '1.519'
Method build_freestyle_config
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
def build_freestyle_config(params)
# Supported SCM providers
supported_scm = ["git", "subversion", "cvs"]
# Set default values for params that are not specified.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File client.rb
has 485 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rubygems'
require 'json'
require 'net/http'
require 'net/https'
require 'nokogiri'
Method initialize
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def initialize(args)
args = symbolize_keys(args)
args.each do |key, value|
if value && VALID_PARAMS.include?(key.to_s)
instance_variable_set("@#{key}", value)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class Client
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class Client
attr_accessor :timeout, :logger
# Default port to be used to connect to Jenkins
DEFAULT_SERVER_PORT = 8080
# Default timeout in seconds to be used while performing operations
Method build_freestyle_config
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_freestyle_config(params)
# Supported SCM providers
supported_scm = ["git", "subversion", "cvs"]
# Set default values for params that are not specified.
Method get_build_params
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_build_params(job_name)
@logger.info "Obtaining the build params of '#{job_name}'"
xml = get_config(job_name)
n_xml = Nokogiri::XML(xml)
params = n_xml.xpath("//parameterDefinitions").first
Method get_build_id_the_old_way
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def get_build_id_the_old_way(expected_build_id, opts)
# Try to wait until the build starts so we can mimic queue
# Wait for the build to start
build_start_timeout = opts['build_start_timeout']
poll_interval = opts['poll_interval'] || 2
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create_list_view
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_list_view(params)
# Name is a required parameter. Raise an error if not specified
raise ArgumentError, "Name is required for creating view" \
unless params.is_a?(Hash) && params[:name]
create(params[:name], "listview")
Method get_build_id_from_queue
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_build_id_from_queue(response, expected_build_id, opts)
# If we get this far the API hasn't detected an error response (it would raise Exception)
# So no need to check response code
# Obtain the queue ID from the location
# header and wait till the build is moved to one of the executors and a
Method make_http_request
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def make_http_request(request, follow_redirect = @follow_redirects)
request.basic_auth @username, @password if @username
request['Cookie'] = @cookies if @cookies
if @proxy_ip
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method skype_notification
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def skype_notification(params, xml)
params[:skype_strategy] = case params[:skype_strategy]
when "all"
"ALL"
when "failure"
Method build
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def build(job_name, params={}, opts = {})
if opts.nil? || opts.is_a?(FalseClass)
opts = {}
elsif opts.is_a?(TrueClass)
opts = { 'build_start_timeout' => @client_timeout }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method create_dumb_slave
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_dumb_slave(params)
unless params[:name] && params[:slave_host] && params[:private_key_file]
raise ArgumentError, "Name, slave host, and private key file are" +
" required for creating a slave."
end
Method initialize
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(args)
args = symbolize_keys(args)
args.each do |key, value|
if value && VALID_PARAMS.include?(key.to_s)
instance_variable_set("@#{key}", value)
Method handle_exception
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_exception(response, to_send = "code", send_json = false)
msg = "HTTP Code: #{response.code}, Response Body: #{response.body}"
@logger.debug msg
case response.code.to_i
# As of Jenkins version 1.519, the job builds return a 201 status code
Method handle_exception
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def handle_exception(response, to_send = "code", send_json = false)
msg = "HTTP Code: #{response.code}, Response Body: #{response.body}"
@logger.debug msg
case response.code.to_i
# As of Jenkins version 1.519, the job builds return a 201 status code
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"