stefan-kolb/nucleus

View on GitHub

Showing 116 of 116 total issues

Method state_created? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

          def state_created?(app, gear_groups, deployments)
            # this state exists, but only within the first seconds before the original deployment is applied
            return true if gear_groups[0][:gears].all? { |gear| gear[:state] == 'new' }

            if app[:keep_deployments].to_i > 1
Severity: Minor
Found in lib/nucleus/adapters/v1/openshift_v2/app_states.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

Function onOAuthComplete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

window.onOAuthComplete = function onOAuthComplete(token,OAuthSchemeKey) {
  if(token) {
    if(token.error) {
      var checkbox = $('input[type=checkbox],.secured')
      checkbox.each(function(pos){
Severity: Minor
Found in public/swagger-ui/lib/swagger-oauth.js - 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

Method set has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def set(entity)
        update_timestamps(entity)

        # finally save to the DB
        if entity.id.nil?
Severity: Minor
Found in lib/nucleus_api/persistence/store.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

Method application_state has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def application_state(app, retrieved_dynos = nil)
            # 1: created, both repo and slug are nil
            return Enums::ApplicationStates::CREATED unless repo_or_slug_content?(app)

            # all subsequent states require dynos to be determined
Severity: Minor
Found in lib/nucleus/adapters/v1/heroku/app_states.rb - About 55 mins 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 tar has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def tar(path)
      string_io = StringIO.new('')
      Gem::Package::TarWriter.new(string_io) do |tar|
        Find.find(path) do |file|
          # do not include the git files
Severity: Minor
Found in lib/nucleus/core/common/files/archiver.rb - About 55 mins 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 add_common_request_params has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def add_common_request_params(params)
        common_params = { connection_timeout: 610, write_timeout: 600, read_timeout: 600 }
        # allow to follow redirects in the APIs
        allowed_status_codes = params.key?(:expects) ? [*params[:expects]] : []
        allowed_status_codes.concat([301, 302, 303, 307, 308]) unless params[:follow_redirects] == false
Severity: Minor
Found in lib/nucleus/core/adapter_extensions/http_client.rb - About 55 mins 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 setup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def setup
      # perform the setup only once
      return if @adapters

      # Initialize the application (import adapters, load DAOs, ...)
Severity: Minor
Found in lib/nucleus/adapter_resolver.rb - About 55 mins 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 handle_error has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def handle_error(error)
          cf_error = error.body.is_a?(Hash) ? error.body[:code] : nil
          case error.status
          when 400
            handle_400_error(error, cf_error)
Severity: Minor
Found in lib/nucleus/adapters/v1/cloud_foundry_v2/cloud_foundry_v2.rb - About 55 mins 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 latest_release has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def latest_release(application_id, retrieved_dynos = nil)
          dynos = web_dynos(application_id, retrieved_dynos)
          if dynos.nil? || dynos.empty?
            log.debug 'no dynos for build detection, fallback to latest release version'
            # this approach might be wrong if the app is rolled-back to a previous release
Severity: Minor
Found in lib/nucleus/adapters/v1/heroku/heroku.rb - About 55 mins 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 runtimes_to_install has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def runtimes_to_install(application)
          return [] unless application[:runtimes]
          runtimes_to_install = []
          application[:runtimes].each do |runtime_identifier|
            # we do not need to install native buildpacks
Severity: Minor
Found in lib/nucleus/adapters/v1/heroku/heroku.rb - About 55 mins 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if (this.options.gfm) {
    if (this.options.tables) {
      this.rules = block.tables;
    } else {
      this.rules = block.gfm;
Severity: Minor
Found in public/swagger-ui/lib/marked.js and 1 other location - About 55 mins to fix
public/swagger-ui/lib/marked.js on lines 530..538

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if (this.options.gfm) {
    if (this.options.breaks) {
      this.rules = inline.breaks;
    } else {
      this.rules = inline.gfm;
Severity: Minor
Found in public/swagger-ui/lib/marked.js and 1 other location - About 55 mins to fix
public/swagger-ui/lib/marked.js on lines 107..113

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          post ':provider_id/endpoints' do
            # load the vendor and verify it is valid
            provider = load_provider
            # If validation passed, all required fields are available and not null (unless explicitly allowed).
            # Fields that were not allowed (id, ...) are excluded via declared(params)
Severity: Minor
Found in lib/nucleus_api/api/versions/v1/providers.rb and 1 other location - About 50 mins to fix
lib/nucleus_api/api/versions/v1/vendors.rb on lines 64..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          post ':vendor_id/providers' do
            # load the vendor and verify it is valid
            vendor = load_vendor
            # If validation passed, all required fields are available and not null (unless explicitly allowed).
            # Fields that were not allowed (id, ...) are excluded via declared(params)
Severity: Minor
Found in lib/nucleus_api/api/versions/v1/vendors.rb and 1 other location - About 50 mins to fix
lib/nucleus_api/api/versions/v1/providers.rb on lines 57..72

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 42.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid deeply nested control flow statements.
Open

            for(var i=0; i < requiredScopes.length; i++) {
              var s = requiredScopes[i];
              if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
                diff.push(s);
              }
Severity: Major
Found in public/swagger-ui/lib/swagger-oauth.js - About 45 mins to fix

    Method write_zip_entries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_zip_entries(path, sub_path, io)
          search_path = File.join(path, sub_path)
          Find.find(path) do |file|
            zip_file_path = file.sub(%r{^#{Regexp.escape search_path}\/?}, '')
            next if @exclude_git && zip_file_path.start_with?('.git')
    Severity: Minor
    Found in lib/nucleus/core/common/files/archiver.rb - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                if(diff.length > 0){
                  o = v.parentNode.parentNode;
                  $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
                  $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
    
    
    Severity: Major
    Found in public/swagger-ui/lib/swagger-oauth.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (!loose) loose = next;
      Severity: Major
      Found in public/swagger-ui/lib/marked.js - About 45 mins to fix

        Method application_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                  def application_state(app_resource)
                    if app_resource[:entity][:state] == 'STARTED'
                      # 1: crashed
                      return Enums::ApplicationStates::CRASHED if app_resource[:entity][:package_state] == 'FAILED'
                      # 1: started
        Severity: Minor
        Found in lib/nucleus/adapters/v1/cloud_foundry_v2/app_states.rb - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                  for(scope in auth.scopes) {
                    scopes.push({scope: scope, description: auth.scopes[scope], OAuthSchemeKey: key});
                  }
        Severity: Major
        Found in public/swagger-ui/lib/swagger-oauth.js - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language