publiclab/spectral-workbench

View on GitHub

Showing 127 of 127 total issues

Method destroy has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    @tag = Tag.find(params[:id])
    if @tag
      if @tag.user_id == current_user.id || current_user.role == 'admin'
        if @tag.is_deletable?
Severity: Minor
Found in app/controllers/tags_controller.rb - About 3 hrs 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 create has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create # rubocop:disable Metrics/AbcSize
    if logged_in? || params[:token] && User.find_by_token(params[:token])

      user = current_user || User.find_by_token(params[:token])
      params[:spectrum][:json] = params[:spectrum][:data] if params[:spectrum] && params[:spectrum][:data]
Severity: Major
Found in app/controllers/spectrums_controller.rb - About 3 hrs to fix

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

        if (loc.coords) {
          $('#lat').val(loc.coords.latitude)
          $('#lon').val(loc.coords.longitude)
        }
        else {
    Severity: Major
    Found in app/assets/javascripts/capture.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/upload.js on lines 17..27

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

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

        if (loc.coords) {
    
          $('#lat').val(loc.coords.latitude)
          $('#lon').val(loc.coords.longitude)
    
    
    Severity: Major
    Found in app/assets/javascripts/upload.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/capture.js on lines 348..355

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

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

      def index
        if params[:set_id]
          @set = Set.find params[:set_id]
          render partial: 'tags/inlineList', locals: { datum: @set }, layout: false
        elsif params[:spectrum_id]
    Severity: Minor
    Found in app/controllers/tags_controller.rb - About 3 hrs 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

    File analyze.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    //= require graph.js
    var ajax_load = "<img src='/images/spinner-small.gif' alt='loading...' />";
    spectrum = "";
    var legends;
    $W = {
    Severity: Minor
    Found in app/assets/javascripts/analyze.js - About 2 hrs to fix

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

        def index
          @offline = 'flush'
          if logged_in?
            if params[:calibration_id] == 'calibration'
              @calibration = nil
      Severity: Major
      Found in app/controllers/capture_controller.rb and 1 other location - About 2 hrs to fix
      app/controllers/capture_controller.rb on lines 30..47

      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

        def index2
          @offline = 'flush'
          if logged_in?
            if params[:calibration_id] == 'calibration'
              @calibration = nil
      Severity: Major
      Found in app/controllers/capture_controller.rb and 1 other location - About 2 hrs to fix
      app/controllers/capture_controller.rb on lines 11..28

      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

      Function initialize has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initialize: function(args) {
          this.spectrum_id = args['spectrum_id']
          this.sample_row = args['sample_row']
          this.calibrated = args['calibrated']
          this.form_authenticity_token = args['form_authenticity_token']
      Severity: Major
      Found in app/assets/javascripts/analyze.js - About 2 hrs to fix

        Method show has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            @spectrum = Spectrum.find(params[:id])
            respond_with(@spectrum) do |format|
              format.html do
                # temporary routing until we deprecate 1.0 paths to /legacy
        Severity: Minor
        Found in app/controllers/spectrums_controller.rb - About 2 hrs 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 save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          def save
            # be sure there's a "login" field here too, so users don't lose data when they're required to log in.
            @spectrum = Spectrum.new(
              title: params[:title],
              author: current_user.login,
        Severity: Minor
        Found in app/controllers/capture_controller.rb - About 2 hrs 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

        Class Tag has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Tag < ActiveRecord::Base
          validates_presence_of :name, on: :create, message: "can't be blank"
          validates_presence_of :user_id, on: :create, message: "can't be blank"
          validates_presence_of :spectrum_id, on: :create, message: "can't be blank"
        
        
        Severity: Minor
        Found in app/models/tag.rb - About 2 hrs to fix

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

            def create
              @response = {
                errors: [],
                saved: {}
              }
          Severity: Minor
          Found in app/controllers/tags_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

          Function initialize has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            initialize: function(args) {
              this.mobile = args['mobile'] || false
              this.flipped = args['flipped'] == true || false
              this.interface = args['interface'] || false
              this.mode = args['mode'] || 'combined'
          Severity: Minor
          Found in app/assets/javascripts/capture.js - About 1 hr to fix

            Function auto_detect_sample_row has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              auto_detect_sample_row: function() {
                    
                // We need a separate canvas to draw the snapshot, whenever we try to auto detect the sample row.
                if ($('#autoDetectCanvas').length == 0) {
                  $('body').append("<canvas style='display:none;' id='autoDetectCanvas'></canvas>")
            Severity: Minor
            Found in app/assets/javascripts/capture.js - About 1 hr to fix

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

                def openid_authentication(openid_url, back_to)
                  # puts openid_url
                  authenticate_with_open_id(openid_url, required: %i(nickname email fullname)) do |result, identity_url, registration|
                    dummy_identity_url = identity_url
                    dummy_identity_url = dummy_identity_url.split('/')
              Severity: Minor
              Found in app/controllers/sessions_controller.rb - About 1 hr to fix

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

                  def update
                    @spectrum = Spectrum.find(params[:id])
                    require_ownership(@spectrum)
                
                    @spectrum.title = params[:spectrum][:title] unless params[:spectrum].nil? || params[:spectrum][:title].nil?
                Severity: Minor
                Found in app/controllers/spectrums_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 index has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def index
                    @offline = 'flush'
                    if logged_in?
                      if params[:calibration_id] == 'calibration'
                        @calibration = nil
                Severity: Minor
                Found in app/controllers/capture_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 index2 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def index2
                    @offline = 'flush'
                    if logged_in?
                      if params[:calibration_id] == 'calibration'
                        @calibration = nil
                Severity: Minor
                Found in app/controllers/capture_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

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

                    } else {
                      style.webkitTransform = "scaleX(1)"
                      style.mozTransform = "scaleX(1)"
                      style.oTransform = "scaleX(1)"
                      style.transform = "scaleX(1)"
                Severity: Major
                Found in app/assets/javascripts/capture.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/capture.js on lines 551..558

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

                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

                Severity
                Category
                Status
                Source
                Language