openSNP/snpr

View on GitHub
app/controllers/snps_controller.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method make_annotation has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def make_annotation(result, snp, name)
    # TODO: Refactor this. - Helge
    result[name] = {}
    result[name]['name'] = snp.name
    result[name]['chromosome'] = snp.chromosome
Severity: Major
Found in app/controllers/snps_controller.rb - About 2 hrs to fix

    Method json_element has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def json_element(params)
        # TODO: Refactor this. - Helge
        @result = {}
        begin
          @snp = params[:snp] || Snp.find_by_name(params[:snp_name].downcase)
    Severity: Minor
    Found in app/controllers/snps_controller.rb - About 1 hr to fix

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

        def json_annotation
          result = {}
          if params[:snp_name].index(',')
            snps = params[:snp_name].split(',')
            snps.each do |s|
      Severity: Minor
      Found in app/controllers/snps_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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          @snp = Snp.includes(:snp_comments).
            where(name: params[:id].downcase).first || not_found
      
          if params[:format] == 'json'
      Severity: Minor
      Found in app/controllers/snps_controller.rb - About 35 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      There are no issues that match your filters.

      Category
      Status