SysMO-DB/seek

View on GitHub

Showing 1,025 of 1,025 total issues

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

    respond_to do |format|
      if @presentation.save

        # update attributions
        Relationship.create_or_update_attributions(@presentation, params[:attributions])
Severity: Major
Found in app/controllers/presentations_controller.rb and 1 other location - About 2 hrs to fix
app/controllers/models_controller.rb on lines 428..458

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

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

Function detect_browser has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function detect_browser(){
    var browser = new Object();
    browser.name  = navigator.appName;
    browser.fullVersion  = ''+parseFloat(navigator.appVersion);
    browser.majorVersion = parseInt(navigator.appVersion,10);
Severity: Minor
Found in app/assets/javascripts/detect_browser.js - About 2 hrs to fix

    Method update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update
        group_name = white_list(params[:favourite_group_name])
        found = FavouriteGroup.where(:name => group_name, :user_id => current_user.id).first
        
        # if the found group with the same is the current one - that's fine; otherwise - can't rename a group with such new name 
    Severity: Minor
    Found in app/controllers/favourite_groups_controller.rb - About 2 hrs to fix

      Method explicit_versioning has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def explicit_versioning(options = {}, &extension)
                # don't allow multiple calls
                return if self.included_modules.include?(Jits::Acts::ExplicitVersioning::ActMethods)
      
                send :include, Jits::Acts::ExplicitVersioning::ActMethods
      Severity: Minor
      Found in lib/explicit_versioning.rb - About 2 hrs to fix

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

        function removeOrganism(id) {
        
            for(var i = 0; i < organisms.length; i++)
                if(organisms[i][1] == id) {
                    organisms.splice(i, 1);
        Severity: Major
        Found in app/assets/javascripts/projects.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/people.js on lines 20..30

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

        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 removeDiscipline(id) {
            
            for(var i = 0; i < disciplines.length; i++)
                if(disciplines[i][1] == id) {
                    disciplines.splice(i, 1);
        Severity: Major
        Found in app/assets/javascripts/people.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/projects.js on lines 21..31

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

        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

          def uniq_term_uri_combined_with_title
             if self.new_record?
               errors[:base] << "Assay type with label #{self.title} and parent #{self.parents.first.try(:title)} already exists!" if AssayType.all.detect{|at| at.title == self.title && at.term_uri == self.term_uri}
             else
               errors[:base] << "Assay type with label #{self.title} and parent #{self.parents.first.try(:title)} already exists!" if AssayType.all.detect{|at| at.id != self.id && at.title == self.title && at.term_uri == self.term_uri}
        Severity: Major
        Found in app/models/assay_type.rb and 1 other location - About 2 hrs to fix
        app/models/technology_type.rb on lines 32..36

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

        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

          def uniq_term_uri_combined_with_title
            if self.new_record?
              errors[:base] << "Technology type with label #{self.title} and parent #{self.parents.first.try(:title)} already exists!" if TechnologyType.all.detect { |at| at.title == self.title && at.term_uri == self.term_uri }
            else
              errors[:base] << "Technology type with label #{self.title} and parent #{self.parents.first.try(:title)} already exists!" if TechnologyType.all.detect { |at| at.id != self.id && at.title == self.title && at.term_uri == self.term_uri }
        Severity: Major
        Found in app/models/technology_type.rb and 1 other location - About 2 hrs to fix
        app/models/assay_type.rb on lines 31..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 77.

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

            def empty_mapping # defines basic mapping to start with, not that useful for the real parsing business ;-)
              {
                  :name => "",
                  :data_row_offset => 1, # add this to the row of a header column to get to row with the first data element
        
        
        Severity: Minor
        Found in lib/seek/parser_mapper.rb - About 1 hr to fix

          Method jena_mapping has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def jena_mapping
                {
                    :name => "jena",
                    :data_row_offset => 2,
          
          
          Severity: Minor
          Found in lib/seek/parser_mapper.rb - About 1 hr to fix

            Function validateResourceFields has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            function validateResourceFields(is_new_file, resource_name, is_managed) {
                // check if sharing rights are defined
                if (!($(document.getElementById('sharing_scope_0')).checked) &&
                    !($(document.getElementById('sharing_scope_2')).checked) &&
                    !($(document.getElementById('sharing_scope_4')).checked))
            Severity: Minor
            Found in app/assets/javascripts/resource.js - 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 to_presentation_version has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_presentation_version
                  Presentation::Version.new.tap do |presentation_version|
                    presentation_version.attributes.keys.each do |attr|
                      presentation_version.send("#{attr}=", send("#{attr}")) if respond_to? attr and attr!="id"
                    end
            Severity: Minor
            Found in app/models/data_file.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 detect_browser has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            function detect_browser(){
                var browser = new Object();
                browser.name  = navigator.appName;
                browser.fullVersion  = ''+parseFloat(navigator.appVersion);
                browser.majorVersion = parseInt(navigator.appVersion,10);
            Severity: Minor
            Found in app/assets/javascripts/detect_browser.js - 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 filter_feeds_entries_with_chronological_order has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def filter_feeds_entries_with_chronological_order feeds, number_of_entries=10
                filtered_entries = []
                unless feeds.blank?
                  feeds.each do |feed|
                     entries = try_block{feed.entries}
            Severity: Minor
            Found in app/helpers/homes_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 authorize_related_items has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def authorize_related_items(related)
                related.each do |key, res|
                  res[:items].uniq!
                  res[:items].compact!
                  unless res[:items].empty?
            Severity: Minor
            Found in app/helpers/assets_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 process_permissions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def process_permissions permissions, resource_name, display_no_access=false
                #remove the permissions with access_type=NO_ACCESS
                permissions.select!{ |p| p.access_type != Policy::NO_ACCESS } unless display_no_access
            
                html = ''
            Severity: Minor
            Found in app/helpers/policy_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 recent_project_changes_hash has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def recent_project_changes_hash
            
                projects=current_user.person.projects
                
                people=Person.order('updated_at DESC')
            Severity: Minor
            Found in app/helpers/homes_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 update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                # remove protected columns (including a "link" to content blob - actual data cannot be updated!)
                if params[:sop]
                  [:contributor_id, :contributor_type, :original_filename, :content_type, :content_blob_id, :created_at, :updated_at, :last_used_at].each do |column_name|
                    params[:sop].delete(column_name)
            Severity: Minor
            Found in app/controllers/sops_controller.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 update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                data_file_ids = (params[:sample_data_file_ids].nil? ? [] : params[:sample_data_file_ids].reject(&:blank?)) || []
                model_ids = (params[:sample_model_ids].nil? ? [] : params[:sample_model_ids].reject(&:blank?)) || []
                sop_ids = (params[:sample_sop_ids].nil? ? [] : params[:sample_sop_ids].reject(&:blank?)) || []
                @sample.attributes = params[:sample]
            Severity: Minor
            Found in app/controllers/samples_controller.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 update_params_for_batch has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                  def update_params_for_batch(params)
                    data = []
                    data_urls = []
                    original_filenames = []
                    make_local_copy = []
            Severity: Minor
            Found in lib/seek/upload_handling/parameter_handling.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

            Severity
            Category
            Status
            Source
            Language