Showing 93 of 93 total issues

File entities.rb has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "api/helpers"

module API
  # Entities is a module that groups all the classes to be used as Grape
  # entities.
Severity: Minor
Found in lib/api/entities.rb - About 7 hrs to fix

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

    function exists(value, options) {
      return searchTeam(value, options)
        .then((response) => {
          const collection = response.data;
    
    
    Severity: Major
    Found in app/assets/javascripts/modules/teams/service.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/modules/teams/service.js on lines 87..101

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

    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 memberExists(teamId, value) {
      return searchMember(teamId, value)
        .then((response) => {
          const collection = response.data;
    
    
    Severity: Major
    Found in app/assets/javascripts/modules/teams/service.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/modules/teams/service.js on lines 49..63

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

    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

    Class User has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      include PublicActivity::Common
    
      enum ldap_status: { unchecked: 0, checked: 1, disabled: 2 }
    
    
    Severity: Minor
    Found in app/models/user.rb - About 3 hrs to fix

      File teams.rb has 270 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module API
        module V1
          class Teams < Grape::API
            include PaginationParams
            include OrderingParams
      Severity: Minor
      Found in lib/api/v1/teams.rb - About 2 hrs to fix

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

        $(() => {
          if (!$('body[data-controller="namespaces"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/namespaces/index.js and 4 other locations - About 1 hr to fix
        app/assets/javascripts/modules/admin/registries/index.js on lines 6..20
        app/assets/javascripts/modules/repositories/index.js on lines 6..20
        app/assets/javascripts/modules/teams/index.js on lines 6..20
        app/assets/javascripts/modules/webhooks/index.js on lines 6..20

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

        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 5 locations. Consider refactoring.
        Open

        $(() => {
          if (!$('body[data-controller="admin/registries"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/admin/registries/index.js and 4 other locations - About 1 hr to fix
        app/assets/javascripts/modules/namespaces/index.js on lines 6..20
        app/assets/javascripts/modules/repositories/index.js on lines 6..20
        app/assets/javascripts/modules/teams/index.js on lines 6..20
        app/assets/javascripts/modules/webhooks/index.js on lines 6..20

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

        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 5 locations. Consider refactoring.
        Open

        $(() => {
          if (!$('body[data-controller="teams"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/teams/index.js and 4 other locations - About 1 hr to fix
        app/assets/javascripts/modules/admin/registries/index.js on lines 6..20
        app/assets/javascripts/modules/namespaces/index.js on lines 6..20
        app/assets/javascripts/modules/repositories/index.js on lines 6..20
        app/assets/javascripts/modules/webhooks/index.js on lines 6..20

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

        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 5 locations. Consider refactoring.
        Open

        $(() => {
          if (!$('body[data-controller="repositories"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/repositories/index.js and 4 other locations - About 1 hr to fix
        app/assets/javascripts/modules/admin/registries/index.js on lines 6..20
        app/assets/javascripts/modules/namespaces/index.js on lines 6..20
        app/assets/javascripts/modules/teams/index.js on lines 6..20
        app/assets/javascripts/modules/webhooks/index.js on lines 6..20

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

        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 5 locations. Consider refactoring.
        Open

        $(() => {
          if (!$('body[data-controller="webhooks"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/webhooks/index.js and 4 other locations - About 1 hr to fix
        app/assets/javascripts/modules/admin/registries/index.js on lines 6..20
        app/assets/javascripts/modules/namespaces/index.js on lines 6..20
        app/assets/javascripts/modules/repositories/index.js on lines 6..20
        app/assets/javascripts/modules/teams/index.js on lines 6..20

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

        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

                  resource :namespaces do
                    desc "Returns the list of namespaces for the given team",
                         params:   API::Entities::Teams.documentation.slice(:id),
                         is_array: true,
                         entity:   API::Entities::Namespaces,
        Severity: Major
        Found in lib/api/v1/teams.rb and 1 other location - About 1 hr to fix
        lib/api/v1/namespaces.rb on lines 163..180

        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

                  resource :repositories do
                    desc "Returns the list of the repositories for the given namespace",
                         params:   API::Entities::Namespaces.documentation.slice(:id),
                         is_array: true,
                         entity:   API::Entities::Repositories,
        Severity: Major
        Found in lib/api/v1/namespaces.rb and 1 other location - About 1 hr to fix
        lib/api/v1/teams.rb on lines 169..184

        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 (!$('body[data-route="explore/index"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/explore/pages/index.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/modules/tags/index.js on lines 5..18

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

        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 (!$('body[data-controller="tags"]').length) {
            return;
          }
        
        
        Severity: Major
        Found in app/assets/javascripts/modules/tags/index.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/modules/explore/pages/index.js on lines 5..18

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

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

          def get_repo_link_tag(activity)
            tr = activity.trackable
        
            if tr.nil? || tr.is_a?(Registry)
              if repo_name(activity).nil?
        Severity: Minor
        Found in app/helpers/repositories_helper.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 execute! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def execute!
                digests = []
        
                Tag.where(scanned: Tag.statuses[:scan_none]).find_each do |tag|
                  # This may happen when pushing multiple images with the same digest at
        Severity: Minor
        Found in lib/portus/background/security_scanning.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 ready has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.ready
                server = APP_CONFIG["security"]["clair"]["server"]
                return [nil, false] if server.blank?
        
                uri = URI.join(health_endpoint(server), "/health")
        Severity: Minor
        Found in lib/portus/health_checks/clair.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 find_group has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def find_group(name)
                return [] if APP_CONFIG.disabled?("ldap")
        
                connection = initialized_adapter
                options    = search_options_for(filter: "(cn=#{name})", attributes: %w[member uniqueMember])
        Severity: Minor
        Found in lib/portus/ldap/search.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 layer_vulnerabilities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def layer_vulnerabilities(digest)
                layer = fetch_layer(digest)
                return [] if layer.nil?
        
                res = []
        Severity: Minor
        Found in lib/portus/security_backends/clair.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 check_account has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def check_account(account)
                if account == "portus"
                  @reason = "Portus user does not go through LDAP"
                  false
                elsif @username.present?
        Severity: Minor
        Found in lib/portus/ldap/configuration.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

        Severity
        Category
        Status
        Source
        Language