samvera/curation_concerns

View on GitHub

Showing 58 of 58 total issues

Function curationConcernsUploader has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.fn.curationConcernsUploader = function( options ) {

    // Create some defaults, extending them with any options that were provided
    // option afterSubmit: function(form, event, data)
    var settings = $.extend( { }, options);
Severity: Major
Found in app/assets/javascripts/curation_concerns/uploader.js - About 4 hrs to fix

    Class Configuration has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Configuration
        include Callbacks
    
        def initialize
          @registered_concerns = []
    Severity: Minor
    Found in lib/curation_concerns/configuration.rb - About 3 hrs to fix

      Class ResourceStatisticsSource has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ResourceStatisticsSource
          attr_accessor :search_builder, :repository
          def initialize(search_builder: ::CurationConcerns::AdminController.new.search_builder, repository: ::CurationConcerns::AdminController.new.repository)
            # Remove gated discovery.
            @search_builder = search_builder.except(:add_access_controls_to_solr_params)
      Severity: Minor
      Found in app/sources/curation_concerns/resource_statistics_source.rb - About 2 hrs to fix

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

          module LeasesControllerBehavior
            extend ActiveSupport::Concern
            include CurationConcerns::ManagesEmbargoes
            include CurationConcerns::Collections::AcceptsBatches
        
        
        app/controllers/concerns/curation_concerns/embargoes_controller_behavior.rb on lines 2..35

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

        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

          module EmbargoesControllerBehavior
            extend ActiveSupport::Concern
            include CurationConcerns::ManagesEmbargoes
            include CurationConcerns::Collections::AcceptsBatches
        
        
        app/controllers/concerns/curation_concerns/leases_controller_behavior.rb on lines 2..34

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

        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 default_responses has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.default_responses
              {
                success: {
                  code: 200,
                  message: "Request Succeeded",
        Severity: Major
        Found in app/controllers/concerns/curation_concerns/api.rb - About 2 hrs to fix

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

            config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
              b.use :html5
              b.use :placeholder
              b.optional :maxlength
              b.optional :pattern
          lib/generators/curation_concerns/templates/config/initializers/simple_form_bootstrap.rb on lines 11..22

          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

            config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
              b.use :html5
              b.use :placeholder
              b.optional :maxlength
              b.optional :pattern
          lib/generators/curation_concerns/templates/config/initializers/simple_form_bootstrap.rb on lines 113..124

          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

          Method scope_agents_associated_with_entity_and_role has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def scope_agents_associated_with_entity_and_role(entity:, role:)
                  entity = PowerConverter.convert_to_sipity_entity(entity)
                  role = PowerConverter.convert_to_sipity_role(role)
                  workflow_roles = Sipity::WorkflowRole.arel_table
                  workflow_responsibilities = Sipity::WorkflowResponsibility.arel_table
          Severity: Minor
          Found in app/services/curation_concerns/workflow/permission_query.rb - About 1 hr to fix

            Function singleUseLinks has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              $.fn.singleUseLinks = function( options ) {
            
                var clipboard = new Clipboard('.copy-single-use-link');
            
                var manager = {

              Method perform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                def perform(work)
                  work.file_sets.each do |file|
                    file.visibility = work.visibility # visibility must come first, because it can clear an embargo/lease
                    if work.lease
                      file.build_lease unless file.lease
              Severity: Minor
              Found in app/jobs/visibility_copy_job.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 curation_concerns_basic_routes has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def curation_concerns_basic_routes(&block)
                    resources :downloads, only: :show
                    resources :upload_sets, only: [:edit, :update]
              
                    namespace :curation_concerns, path: :concern do
              Severity: Minor
              Found in lib/curation_concerns/rails/routes.rb - About 1 hr to fix

                Method scope_entities_for_the_user has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def scope_entities_for_the_user(user:)
                        entities = Sipity::Entity.arel_table
                        workflow_state_actions = Sipity::WorkflowStateAction.arel_table
                        workflow_states = Sipity::WorkflowState.arel_table
                        workflow_state_action_permissions = Sipity::WorkflowStateActionPermission.arel_table
                Severity: Minor
                Found in app/services/curation_concerns/workflow/permission_query.rb - About 1 hr to fix

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

                      def update
                        success = if wants_to_revert?
                                    actor.revert_content(params[:revision])
                                  elsif params.key?(:file_set)
                                    if params[:file_set].key?(:files)

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

                        def audit_stat(file)
                          audit_results = audit_file(file).collect { |result| result['pass'] }
                          # check how many non runs we had
                          non_runs = audit_results.reduce(0) { |sum, value| value == NO_RUNS ? sum + 1 : sum }
                          if non_runs == 0
                  Severity: Minor
                  Found in app/services/curation_concerns/file_set_audit_service.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 dashboard_configuration has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def dashboard_configuration
                        @dashboard_configuration ||= {
                          menu: {
                            index: {},
                            resource_details: {},
                  Severity: Minor
                  Found in lib/curation_concerns/configuration.rb - About 1 hr to fix

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

                        def create_from_upload(params)
                          # check error condition No files
                          return render_json_response(response_type: :bad_request, options: { message: 'Error! No file to save' }) unless params.key?(:file_set) && params.fetch(:file_set).key?(:files)
                    
                          file = params[:file_set][:files].detect { |f| f.respond_to?(:original_filename) }

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

                          def call(object)
                            return default_image unless object.thumbnail_id
                    
                            thumb = fetch_thumbnail(object)
                            return unless thumb
                    Severity: Minor
                    Found in app/services/curation_concerns/thumbnail_path_service.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function pie_chart has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      $.fn.pie_chart = function(title, data) {
                        // Create the chart
                        $(this).highcharts({
                            chart: {
                                type: 'pie'
                    Severity: Minor
                    Found in app/assets/javascripts/curation_concerns/charts.js - About 1 hr to fix

                      Method create_derivatives has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def create_derivatives(filename)
                              case mime_type
                              when *self.class.pdf_mime_types
                                Hydra::Derivatives::PdfDerivatives.create(filename,
                                                                          outputs: [{ label: :thumbnail, format: 'jpg', size: '338x493', url: derivative_url('thumbnail') }])
                      Severity: Minor
                      Found in app/models/concerns/curation_concerns/file_set/derivatives.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language