jbox-web/redmine_git_hosting

View on GitHub

Showing 79 of 79 total issues

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

  def mirror_configuration
    if mirror_mode?
      reset_fields
    elsif include_all_branches? && include_all_tags?
      mutual_exclusion_error
Severity: Minor
Found in app/models/repository_mirror.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 sync_with_github has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def sync_with_github
        create_relation = false

        ## We don't have stored relation
        if github_issue.nil?
Severity: Minor
Found in app/services/redmine_hooks/github_issues_sync.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 get_cache has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def get_cache(repo_id, command)
          cached = GitCache.find_by_repo_identifier_and_command(repo_id, command)
          if cached
            if valid_cache_entry?(cached.created_at)
              # Update updated_at flag
Severity: Minor
Found in lib/redmine_git_hosting/cache/database.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 do_call_webservice has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def do_call_webservice(payload)
        post_failed, post_message = self.send(use_method, post_receive_url.url, { data: { payload: payload } })

        if post_failed
          logger.error('Failed!')
Severity: Minor
Found in app/services/redmine_hooks/call_webservices.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

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

    def git_config
      repo_conf = {}

      # This is needed for all Redmine repositories
      repo_conf['redminegitolite.projectid']     = project.identifier.to_s
Severity: Minor
Found in app/models/concerns/gitolitable/config.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

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

        def auth!
          if @auth.provided?
            return bad_request unless @auth.basic?

            # Authentication with username and password
Severity: Minor
Found in lib/redmine_git_hosting/patches/grack_auth_patch.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

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

          this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
Severity: Minor
Found in assets/javascripts/bootstrap/bootstrap_tooltip.js and 1 other location - About 45 mins to fix
assets/javascripts/bootstrap/bootstrap_tooltip.js on lines 59..59

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

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 diff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def diff(path, identifier_from, identifier_to = nil, opts = {})
          path ||= ''
          cmd_args = []
          if identifier_to
            cmd_args << 'diff' << '--no-color' << identifier_to << identifier_from
Severity: Minor
Found in lib/redmine/scm/adapters/xitolite_adapter.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

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

      def additional_constraints_on_identifier
        if !identifier.blank? && (new_record? || identifier_changed?)
          errors.add(:identifier, :cannot_equal_project) if Project.find_by_identifier(identifier)

          # See if a repo for another project has the same identifier (existing validations already check for current project)
Severity: Minor
Found in app/models/concerns/gitolitable/validations.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

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

          this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
Severity: Minor
Found in assets/javascripts/bootstrap/bootstrap_tooltip.js and 1 other location - About 45 mins to fix
assets/javascripts/bootstrap/bootstrap_tooltip.js on lines 60..60

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

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 create_member has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_member(ids, current_ids, klass, opts = {}, &block)
Severity: Minor
Found in app/use_cases/repository_protected_branches/member_manager.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def initialize(url, root_url = nil, login = nil, password = nil, path_encoding = nil)
    Severity: Minor
    Found in lib/redmine/scm/adapters/xitolite_adapter.rb - About 35 mins to fix

      Method check_repo_hierarchy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_repo_hierarchy
            ## Storage infos has changed, move repositories!
            if value_has_changed?(:gitolite_global_storage_dir)  ||
               value_has_changed?(:gitolite_redmine_storage_dir) ||
               value_has_changed?(:hierarchical_organisation)
      Severity: Minor
      Found in app/use_cases/settings/apply.rb - About 35 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

            def execute_update_mirrors_hook
              message = 'Notifying mirrors about changes to this repository :'
              y = ''
      
              ## Post to each post-receive URL
      Severity: Minor
      Found in app/use_cases/repositories/execute_hooks.rb and 1 other location - About 35 mins to fix
      app/use_cases/repositories/execute_hooks.rb on lines 61..75

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

      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 commits_per_author_with_aliases has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def commits_per_author_with_aliases
            return @commits_per_author_with_aliases if !@commits_per_author_with_aliases.nil?
            @commits_per_author_with_aliases = nil
      
            registered_committers = []
      Severity: Minor
      Found in app/reports/repository_contributors_stats.rb - About 35 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 key_uniqueness has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def key_uniqueness
          return unless new_record?
      
          existing = GitolitePublicKey.find_by_fingerprint(fingerprint)
          return unless existing
      Severity: Minor
      Found in app/models/gitolite_public_key.rb - About 35 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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def destroy
          return unless request.delete?
      
          if @gitolite_public_key.user == @user || @user.admin?
            if @gitolite_public_key.destroy
      Severity: Minor
      Found in app/controllers/gitolite_public_keys_controller.rb - About 35 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 get_hour_from_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_hour_from_date(date)
          return nil unless date
      
          time = date.to_time
          zone = User.current.time_zone
      Severity: Minor
      Found in app/reports/report_helper.rb - About 35 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 default_repository_has_identifier has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def default_repository_has_identifier
              if project && (is_default? || set_as_default?)
                possibles = Repository.where("project_id = ? and (identifier = '' or identifier is null)", project.id)
                errors.add(:base, :blank_default_exists) if possibles.any? && (new_record? || possibles.detect { |x| x.id != id })
              end
      Severity: Minor
      Found in app/models/concerns/gitolitable/validations.rb - About 35 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 parse_refspec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_refspec(spec)
              parsed_refspec = spec.match(REF_COMPONENT_REGEX)
              return nil if parsed_refspec.nil?
              if parsed_refspec[1]
                # Should be first class.  If no type component, return fail
      Severity: Minor
      Found in lib/redmine_git_hosting/utils/git.rb - About 35 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

      Severity
      Category
      Status
      Source
      Language