orange-cloudfoundry/cf-ops-automation

View on GitHub

Showing 957 of 959 total issues

Method has too many lines. [14/10]
Open

  def download_boshrelease(url, boshrelease_filename, download_path, max_retry = 3)
    retries ||= 0
    puts "Start downloading #{boshrelease_filename} from #{url}"
    begin
      download(url, download_path)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [14/10]
Open

  def fallback_to_bosh_io(errors, fallback_fixes, repackaged_releases_fallback_path)
    successfully_processed = []
    @repackaged_errors.each do |name, details|
      puts "Failed to repackage #{name} boshrelease, trying direct download from bosh.io"
      begin

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [14/10]
Open

      def generated_pipeline_vars(bosh_config, git_server_ip)
        {
          "bosh-target"                               => bosh_config.target,
          "bosh-username"                             => bosh_config.client,
          "bosh-password"                             => bosh_config.client_secret,

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [14/10]
Open

  def clone_git_repository(boshrelease_name, git_url, base_git_clones_path, logs_path)
    git_clone_path = File.join(base_git_clones_path, boshrelease_name)
    error_message = ""
    status = nil
    cmd_line = "git clone \"#{git_url}\" \"#{git_clone_path}\""

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method migrate_to_root_deployment_yml has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def migrate_to_root_deployment_yml(paas_template_root)
  root_deployment_migrated = 0
  incomplete_releases = {}
  root_deployments_path = Dir["#{paas_template_root}/*-depls"]
  puts root_deployments_path
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-paas-template.rb - About 2 hrs to fix

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 has too many lines. [13/10]
Open

  def generate_boshrelease_namespaces(repackaged_releases_path, successfully_processed)
    File.open(File.join(repackaged_releases_path, 'boshreleases-namespaces.csv'), 'w+') do |file|
      successfully_processed.each do |name|
        version = @root_deployment.release_version(name)
        release_details = @root_deployment.release(name)&.dig('repository')

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [13/10]
Open

  def filter_releases
    active_releases = @list_releases_command_holder.execute
    puts "Filtering releases"
    boshreleases_git_urls = @root_deployment.releases_git_urls
    boshreleases_git_urls.delete_if do |name, _url|

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [13/10]
Open

  def generate_boshrelease_namespaces(repackaged_releases_path, successfully_processed)
    File.open(File.join(repackaged_releases_path, 'boshreleases-namespaces.csv'), 'a') do |file|
      successfully_processed.each do |name|
        version = @repackaged_errors&.dig(name, 'version')
        release_details = @repackaged_errors&.dig(name, 'repository')

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for init_and_push is too high. [18.71/15]
Open

      def init_and_push(repo_path, repo_name)
        logger.log_and_puts :debug, "Init #{repo_name} at <#{repo_path}>"
        coa_submodule_path = "shared-files/cf-ops-automation-reference-dataset-submodule-sample"
        Dir.chdir repo_path do
          submodule_commit_reference = templates_coa_reference_dataset_submodule_sha1(coa_submodule_path, repo_path)
Severity: Minor
Found in lib/coa/env_bootstrapper/git.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [13/10]
Open

      def update_releases(a_release, all_releases)
        name = a_release&.dig('name')
        version = a_release&.dig('version')
        is_deployed = version.end_with?('*')
        as_uncommitted_changes = version.end_with?('+')
Severity: Minor
Found in lib/tasks/bosh/list_releases.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [13/10]
Open

def anonymize_tfvars_files(selected_tfvars_secrets)
  file_counter = 0
  selected_tfvars_secrets.each do |filename|
    current_secrets_tfvars = File.read(filename)

Severity: Minor
Found in scripts/anonymize_secrets.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for validate_credhub_config is too high. [18.25/15]
Open

      def validate_credhub_config
        raise NoActiveStepConfigError.new('credhub.server', 'transform_config_into_credentials') if credhub_config.dig('server').to_s.empty?
        raise NoActiveStepConfigError.new('credhub.client', 'transform_config_into_credentials') if credhub_config.dig('client').to_s.empty?
        raise NoActiveStepConfigError.new('credhub.secret', 'transform_config_into_credentials') if credhub_config.dig('secret').to_s.empty?
      end
Severity: Minor
Found in lib/coa/env_bootstrapper/credhub.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for push_cf_ops_automation is too high. [18.49/15]
Open

      def push_cf_ops_automation
        logger.log_and_puts :debug, "Setup cf_ops_automation push at <#{PROJECT_ROOT_DIR}>"
        Dir.chdir PROJECT_ROOT_DIR do
          remote_name = "remote-" + SecureRandom.hex
          branch_name = "br-" + SecureRandom.hex
Severity: Minor
Found in lib/coa/env_bootstrapper/git.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method insert_pipeline_config has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def insert_pipeline_config(ci_deployment_overview)
  migrated = false
  ci_deployment_overview['ci-deployment']&.each do |_, details|
    additional_pipelines = {}
    details['pipelines']&.select { |name, _| name.end_with?('-init-generated') }
Severity: Minor
Found in upgrade/v3.2.0/01-upgrade-config.rb - About 1 hr to fix

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

Cyclomatic complexity for set_pipeline is too high. [8/6]
Open

def set_pipeline(target_name:, fly_bin: 'fly', team_name: 'main', name:, config:, load: [], options: [])
  if OPTIONS.key?(:match) && !name.include?(OPTIONS[:match])
    puts "Skipping pipeline loading, '--match' #{OPTIONS[:match]} exclude pipeline #{name}"
    return
  end

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for set_pipeline is too high. [8/6]
Open

def set_pipeline(target_name:, fly_bin: 'fly', team_name: 'main', name:, config:, load: [], options: [])
  if OPTIONS.key?(:match) && !name.include?(OPTIONS[:match])
    puts "Skipping pipeline loading, '--match' #{OPTIONS[:match]} exclude pipeline #{name}"
    return
  end

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method has too many lines. [12/10]
Open

def process_credentials_files(target_dir, credentials_files)
  migrated_counter = 0
  credentials_files.each do |file|
    target_file = File.join(target_dir, File.basename(file))
    if File.exist?(target_file)
Severity: Minor
Found in upgrade/v3.2.0/01-upgrade-config.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [12/10]
Open

def load_pipeline_into_concourse(pipeline_name, pipeline_vars_files, pipeline_definition_filename, concourse_target_name)
  raise "No vars_files detected. Please ensure coa-config option is #{OPTIONS[:coa_config]}" if pipeline_vars_files&.empty?

  pipeline_team_name = OPTIONS[:team]
  fly_bin = OPTIONS[:fly_bin]

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [12/10]
Open

def extract_secrets_keys(selected_yaml_file)
  file_counter = 0
  selected_yaml_file.each do |filename|
    current_secrets_yaml = YAML.load_file(filename, aliases: true)
    new_secret_filename = filename.slice(OPTIONS[:secrets_path].length + 1..filename.length)
Severity: Minor
Found in scripts/anonymize_secrets.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [12/10]
Open

  def create_github_download_info(name, details)
    repo = details['repository'] || ""
    version = details['version']
    tag_prefix = details['tag_prefix']
    github_release_name = if details['github-release-name'].to_s.empty?

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Severity
Category
Status
Source
Language