librariesio/libraries.io

View on GitHub

Showing 110 of 146 total issues

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

    def self.create_from_hash(name_with_owner, issue_hash, token = nil)
      issue_hash = issue_hash.to_hash.with_indifferent_access
      repository = Repository.host('GitLab').find_by_full_name(name_with_owner) || RepositoryHost::Gitlab.create(name_with_owner)
      return if repository.nil?
      i = repository.issues.find_or_create_by(uuid: issue_hash[:id])
Severity: Minor
Found in app/models/repository_issue/gitlab.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 emojify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def emojify(content)
    h(content).to_str.gsub(/:([\w+-]+):/) do |match|
      emoji = Emoji.find_by_alias($1)
      if emoji
        %(<img alt="#$1" src="#{image_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
Severity: Minor
Found in app/helpers/application_helper.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 mapping_from_pom_xml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.mapping_from_pom_xml(version_xml, depth = 0)
      if version_xml.respond_to?('project')
        xml = version_xml.project
      else
        xml = version_xml
Severity: Minor
Found in app/models/package_manager/maven.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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @all_counts = @project.repository_dependencies.where('repositories.fork = ?', false).joins(:repository).distinct('repository_dependencies.repository_id').group('repository_dependencies.requirements').count.select{|k,v| k.present? }
    @total = @all_counts.sum{|k,v| v }
    if @all_counts.any?
      @kinds = @project.repository_dependencies.where('repositories.fork = ?', false).joins(:repository).distinct('repository_dependencies.repository_id').group('repository_dependencies.kind').count
Severity: Minor
Found in app/controllers/project_usage_controller.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 perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def perform(host_type, name_with_owner, issue_number, type, token = nil)
Severity: Minor
Found in app/workers/issue_worker.rb - About 35 mins to fix

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

        def self.update(host_type, repo_full_name, issue_number, type, token = nil)
    Severity: Minor
    Found in app/models/repository_issue/base.rb - About 35 mins to fix

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

        def compatible_license?
          return nil unless project
          return nil if project.normalized_licenses.empty?
          return nil if version.project.normalized_licenses.empty?
          project.normalized_licenses.any? do |license|
      Severity: Minor
      Found in app/models/dependency.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 sync_manifest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def sync_manifest(m)
          args = {platform: m[:platform], kind: m[:kind], filepath: m[:path], sha: m[:sha]}
      
          unless manifests.find_by(args)
            manifest = manifests.create(args)
      Severity: Minor
      Found in app/models/concerns/repo_manifests.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 feature_flag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def feature_flag(bool, negative = nil)
          icon_class = bool ? 'check' : 'times'
          color = bool ? 'green' : 'red'
          tag = content_tag :i, '', class: "fa fa-#{icon_class}", style: "color:#{color}"
          !bool && negative ? content_tag(:i, negative) : tag
      Severity: Minor
      Found in app/helpers/application_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 download_orgs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def download_orgs
            return if owner.org?
      
            # GitLab doesn't have an API to get a users public group memberships so we scrape it instead
            rsp = PackageManager::Base.get_json("https://gitlab.com/users/#{owner.login}/groups")
      Severity: Minor
      Found in app/models/repository_owner/gitlab.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 load_repo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def load_repo
          raise ActiveRecord::RecordNotFound unless current_host.present?
          full_name = [params[:owner], params[:name]].join('/')
          @repository = Repository.host(current_host).where('lower(full_name) = ?', full_name.downcase).first
          raise ActiveRecord::RecordNotFound if @repository.nil?
      Severity: Minor
      Found in app/controllers/application_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 format_markup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.format_markup(path, content)
          return unless content.present?
          return unless supported_format?(path)
          GitHub::Markup.render(path, content.force_encoding("UTF-8"))
        rescue GitHub::Markup::CommandError
      Severity: Minor
      Found in app/models/readme.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 download_tags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def download_tags(token = nil)
            remote_tags = api_client(token).repos.tags(repository.owner_name, repository.project_name)
            existing_tag_names = repository.tags.pluck(:name)
            remote_tags.each do |name, data|
              next if existing_tag_names.include?(name)
      Severity: Minor
      Found in app/models/repository_host/bitbucket.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 add_metrics_to_repo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_metrics_to_repo(results)
            # create one hash with all results
            results.reduce(Hash.new, :merge).each do |category, value|
                unless value.nil?
                    stat = repository.repository_maintenance_stats.find_or_create_by(category: category.to_s)
      Severity: Minor
      Found in app/models/repository_host/base.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 search_page_entries_info has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def search_page_entries_info(collection, options = {})
          entry_name = options[:model] || (collection.empty?? 'item' :
              collection.first.class.name.split('::').last.titleize)
          if collection.total_pages < 2
            case collection.size
      Severity: Minor
      Found in app/helpers/application_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 create_from_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.create_from_hash(name_with_owner, issue_hash, token = nil)
            return if issue_hash.nil?
            issue_hash = issue_hash.to_hash
            repository = Repository.host('GitHub').find_by_full_name(name_with_owner) || RepositoryHost::Github.create(name_with_owner)
            return if repository.nil?
      Severity: Minor
      Found in app/models/repository_issue/github.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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          find_platform
      
          top_projects = Project.platform(@platform_name).order('(dependent_repos_count) DESC NULLS LAST').limit(1000).includes(:repository)
      
      
      Severity: Minor
      Found in app/controllers/admin/platforms_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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def run(event, payload)
          case event
          when "create"
            case payload['ref_type']
            when "repository"
      Severity: Minor
      Found in app/services/github_hook_handler.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 compatible_license? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def compatible_license?
          return nil unless project
          return nil if project.normalized_licenses.empty?
          return nil if repository.license.blank?
          project.normalized_licenses.any? do |license|
      Severity: Minor
      Found in app/models/repository_dependency.rb - About 25 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def sync
          check_status
          if status == 'Removed'
            set_last_synced_at
            return
      Severity: Minor
      Found in app/models/project.rb - About 25 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