openSUSE/open-build-service

View on GitHub

Showing 713 of 773 total issues

Method binary_packages has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  def binary_packages
    check_package_access(params[:project], params[:package], false)
    @pkg = Package.find_by_project_and_name(params[:project], params[:package])

    begin
Severity: Minor
Found in src/api/app/controllers/public_controller.rb - About 5 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 find_all_by has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def self.find_all_by(args = {}, opt = {})
      refresh = (opt.symbolize_keys[:cache].to_s == 'refresh')
      exclude_mod = !!opt.symbolize_keys[:exclude_modules]
      filter = args.symbolize_keys.slice(:iso, :state, :build, :maxage, :distri, :version, :group)

Severity: Minor
Found in src/api/app/models/obs_factory/openqa_job.rb - About 5 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 sync_repository_pathes has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def sync_repository_pathes
    # check all my repositories and ..
    repositories.each do |repo|
      cycle_detection = {}
      repo.path_elements.each do |path|
Severity: Minor
Found in src/api/app/models/project.rb - About 4 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 verify_xml! has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def self.verify_xml!(xmlhash)
    xmlhash = Xmlhash.parse(xmlhash) if xmlhash.is_a?(String)
    xmlhash.elements('target') do |p|
      prj = Project.get_by_name(p['project'])
      unless prj.repositories.find_by_name(p['repository'])
Severity: Minor
Found in src/api/app/models/channel.rb - About 4 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 summary has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def summary
      return @summary if @summary
      building = false
      failed = 0
      final = 0
Severity: Minor
Found in src/api/app/presenters/obs_factory/obs_project_presenter.rb - About 4 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

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

    function decrease(cm, elt) {
    this.cm = cm;
    this.height = this.cm.getScrollerElement().offsetHeight - 40;
    this.width  = this.cm.getWrapperElement().offsetWidth - 69;
    this.cm.setSize(this.width, this.height);
Severity: Major
Found in src/api/app/assets/javascripts/webui2/cm2/toolbars.js and 1 other location - About 4 hrs to fix
src/api/app/assets/javascripts/webui2/cm2/toolbars.js on lines 428..435

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 130.

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

    function increase(cm, elt) {
    this.cm = cm;
    this.height = this.cm.getScrollerElement().offsetHeight + 40;
    this.width  = this.cm.getWrapperElement().offsetWidth + 65;
    this.cm.setSize(this.width, this.height);
Severity: Major
Found in src/api/app/assets/javascripts/webui2/cm2/toolbars.js and 1 other location - About 4 hrs to fix
src/api/app/assets/javascripts/webui2/cm2/toolbars.js on lines 441..448

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 130.

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

Method call has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def call(env)
    logger = Rails.logger
    GC.start
    before = %x(ps -orss= -p#{$PROCESS_ID}).to_i
    file = File.new("/tmp/memprof-#{$PROCESS_ID}.log", 'w')
Severity: Minor
Found in src/api/lib/memory_debugger.rb - About 4 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 _merge_pkg_into_maintenance_incident has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def _merge_pkg_into_maintenance_incident(incident_project)
    # recreate package based on link target and throw everything away, except source changes
    # silently as maintenance teams requests ...
    new_pkg = nil

Severity: Minor
Found in src/api/app/models/bs_request_action_maintenance_incident.rb - About 4 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

File webui_helper.rb has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Webui::WebuiHelper
  include ActionView::Helpers::JavaScriptHelper
  include ActionView::Helpers::AssetTagHelper
  include Webui::BuildresultHelper

Severity: Minor
Found in src/api/app/helpers/webui/webui_helper.rb - About 4 hrs to fix

    File application_controller.rb has 352 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_dependency 'opensuse/validator'
    require_dependency 'api_exception'
    require_dependency 'authenticator'
    
    class ApplicationController < ActionController::Base
    Severity: Minor
    Found in src/api/app/controllers/application_controller.rb - About 4 hrs to fix

      Method update_from_xml has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_from_xml(xmlhash)
          xmlhash = Xmlhash.parse(xmlhash) if xmlhash.is_a?(String)
      
          _update_from_xml_targets(xmlhash)
          _update_from_xml_binary_lists(xmlhash)
      Severity: Minor
      Found in src/api/app/models/channel.rb - About 4 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 _update_from_xml_register_pool has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def _update_from_xml_register_pool(rxml)
          rxml.elements('pool') do |u|
            medium = {}
            product_media.each do |pm|
              key = "#{pm.repository.id}/#{pm.name}"
      Severity: Minor
      Found in src/api/app/models/product.rb - About 4 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 package_existence_consistency_check has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def package_existence_consistency_check(project, fix = nil)
          errors = ''
          begin
            project.reload
          rescue ActiveRecord::RecordNotFound
      Severity: Minor
      Found in src/api/app/jobs/consistency_check_job.rb - About 4 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 find has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def find(xpath)
          # logger.debug "---------------------- parsing xpath: #{xpath} -----------------------"
      
          begin
            @stack = @lexer.parse xpath
      Severity: Major
      Found in src/api/lib/xpath_engine.rb - About 4 hrs to fix

        Method save has 101 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def save
            flash[:error] = nil
            # Note: At this point a patchinfo already got created by
            #       Patchinfo.new.create_patchinfo in the new_patchinfo action
            unless valid_summary?(params[:summary])
        Severity: Major
        Found in src/api/app/controllers/webui/patchinfo_controller.rb - About 4 hrs to fix

          Method _assignreview_update_reviews has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

            def _assignreview_update_reviews(reviewer, opts, new_review = nil)
              review_comment = nil
              reviews.reverse_each do |review|
                next if review.by_user
                next if review.by_group && review.by_group != opts[:by_group]
          Severity: Minor
          Found in src/api/app/models/bs_request.rb - About 3 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 find_with_ldap has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.find_with_ldap(login, password)
              Rails.logger.debug("Looking for #{login} using ldap")
          
              # When the server closes the connection, @@ldap_search_con.nil? doesn't catch it
              # @@ldap_search_con.bound? doesn't catch it as well. So when an error occurs, we
          Severity: Minor
          Found in src/api/app/models/user_ldap_strategy.rb - About 3 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 change_review_state has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            def change_review_state(new_review_state, opts = {})
              with_lock do
                new_review_state = new_review_state.to_sym
          
                unless state == :review || (state == :new && new_review_state == :new)
          Severity: Minor
          Found in src/api/app/models/bs_request.rb - About 3 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 store_from_xml has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

            def store_from_xml(hash)
              source = hash.delete('source')
              if source
                self.source_package = source.delete('package')
                self.source_project = source.delete('project')
          Severity: Minor
          Found in src/api/app/models/bs_request_action.rb - About 3 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

          Severity
          Category
          Status
          Source
          Language