SysMO-DB/seek

View on GitHub

Showing 1,025 of 1,025 total issues

Method builder_content has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def builder_content content_blob
          filepath=content_blob.filepath

          #this is necessary to get the correct filename and especially extension, which JWS relies on
          tmpfile = Tempfile.new([content_blob.original_filename,File.extname(content_blob.original_filename)])
Severity: Minor
Found in lib/seek/jws/builder.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 spreadsheet_contents_for_search has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def spreadsheet_contents_for_search obj=self
        if obj.content_blob.is_extractable_spreadsheet?
          content = Rails.cache.fetch("#{obj.content_blob.cache_key}-ss-content-for-search") do
            begin
              xml=obj.spreadsheet_xml
Severity: Minor
Found in lib/seek/data/search_extraction.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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize file, xml=nil, to_populate=true, institution_id = nil
      @file = file

      @investigation = nil
      @study = nil
Severity: Minor
Found in lib/seek/data/bio_samples.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 populate_db has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def populate_db data

      assay = nil
      assay_json = data["assay"]

Severity: Minor
Found in lib/seek/data/bio_samples.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 is_authorized? has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.is_authorized?(action, thing_type, thing, user=nil)

        # initially not authorized, so if all tests fail -
        # safe result of being not authorized will get returned
        is_authorized = false
Severity: Minor
Found in lib/seek/permissions/authorization.rb - About 1 hr to fix

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

      def update
        @study=Study.find(params[:id])
    
        @study.attributes = params[:study]
    
    
    Severity: Major
    Found in app/controllers/studies_controller.rb and 1 other location - About 1 hr to fix
    app/controllers/investigations_controller.rb on lines 99..117

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

    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 update
        @investigation=Investigation.find(params[:id])
    
        @investigation.attributes = params[:investigation]
    
    
    Severity: Major
    Found in app/controllers/investigations_controller.rb and 1 other location - About 1 hr to fix
    app/controllers/studies_controller.rb on lines 82..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 73.

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

    function addSelected(resource_type, source) {
        if (source == "target") {
            for(var key in checkedTargetMap[resource_type]) {
                if (allLinks[resource_type][key] == true) {
    
    
    Severity: Minor
    Found in app/assets/javascripts/link_adder.js - About 1 hr to fix

      Method create has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          @sample = Sample.new(params[:sample])
          # create new specimen only for combined form
          is_new_spec = params[:sample][:specimen_id].nil? ? true : false
      
      
      Severity: Minor
      Found in app/controllers/samples_controller.rb - About 1 hr to fix

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

          def update
        
            #FIXME: would be better to resolve the differences, rather than keep clearing and reading the assets and organisms
            #DOES resolve differences for assets now
            organisms             = params[:assay_organism_ids]||[]
        Severity: Minor
        Found in app/controllers/assays_controller.rb - About 1 hr to fix

          Method create has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create
              params[:assay_class_id] ||= AssayClass.for_type("experimental").id
              @assay        = Assay.new(params[:assay])
          
              organisms     = params[:assay_organism_ids] || []
          Severity: Minor
          Found in app/controllers/assays_controller.rb - About 1 hr to fix

            Method find_and_authorize_requested_item has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def find_and_authorize_requested_item
                begin
                  name = self.controller_name.singularize
                  action = translate_action(action_name)
            
            
            Severity: Minor
            Found in app/controllers/application_controller.rb - About 1 hr to fix

              Function addSelectedOrganism has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function addSelectedOrganism() {
                  selected_option_index=$("possible_organisms").selectedIndex;
                  selected_option=$("possible_organisms").options[selected_option_index];
                  title=selected_option.text;
                  id=selected_option.value;
              Severity: Minor
              Found in app/assets/javascripts/assays.js - About 1 hr to fix

                Method create has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def create
                    @person = Person.new(params[:person])
                
                    redirect_action="new"
                
                
                Severity: Minor
                Found in app/controllers/people_controller.rb - About 1 hr to fix

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                      for (var i=1, l = regexps.length; i < l; i++) {
                        if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
                          return false;
                      };
                  Severity: Major
                  Found in doc/seek/js/searcher.js and 2 other locations - About 1 hr to fix
                  doc/seek/js/searcher.js on lines 89..92
                  doc/seek/js/searcher.js on lines 115..118

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

                  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

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                      for (var i=1, l = regexps.length; i < l; i++) {
                        if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
                          return false;
                      };
                  Severity: Major
                  Found in doc/seek/js/searcher.js and 2 other locations - About 1 hr to fix
                  doc/seek/js/searcher.js on lines 89..92
                  doc/seek/js/searcher.js on lines 128..131

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

                  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

                  Identical blocks of code found in 3 locations. Consider refactoring.
                  Open

                      for (var i=1, l = regexps.length; i < l; i++) {
                        if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
                          return false;
                      };
                  Severity: Major
                  Found in doc/seek/js/searcher.js and 2 other locations - About 1 hr to fix
                  doc/seek/js/searcher.js on lines 115..118
                  doc/seek/js/searcher.js on lines 128..131

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

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

                    def asset_report
                      @no_sidebar=true
                      project_assets = @project.assets | @project.assays | @project.studies | @project.investigations
                      @types=[DataFile,Model,Sop,Presentation,Investigation,Study,Assay]
                      @public_assets = {}
                  Severity: Minor
                  Found in app/controllers/projects_controller.rb - About 1 hr to fix

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

                      def update
                        valid = true
                        unless params[:author].blank?
                          person_ids = params[:author].values.reject {|id_string| id_string == ""}
                          if person_ids.uniq.size == person_ids.size
                    Severity: Minor
                    Found in app/controllers/publications_controller.rb - About 1 hr to fix

                      Function changeRowsPerPage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function changeRowsPerPage(){
                          var current_href = window.location.href;
                          if (current_href.endsWith('#'))
                              current_href = current_href.substring(0,current_href.length-1);
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/spreadsheet_explorer.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

                      Severity
                      Category
                      Status
                      Source
                      Language