publiclab/spectral-workbench

View on GitHub

Showing 84 of 127 total issues

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

      Method index has 42 lines of code (exceeds 25 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 1 hr to fix

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

          def create
            @response = {
              errors: [],
              saved: {}
            }
        Severity: Minor
        Found in app/controllers/tags_controller.rb - About 1 hr to fix

          Method destroy has 40 lines of code (exceeds 25 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 1 hr to fix

            Function toggle_rotation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              toggle_rotation: function() {
                $W.rotated = !$W.rotated
                if ($W.rotated == true) $('.btn-rotate').addClass('active');
                else                    $('.btn-rotate').removeClass('active');
                var style = $('#heightIndicator')[0].style
            Severity: Minor
            Found in app/assets/javascripts/capture.js - About 1 hr to fix

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

                  setup: function(min_width,min_height,min_slope,threshold,pixels,wavelengths) {
                    min_width = min_width || 7 // min peak width to search for
                    min_height = min_height || 20 // min peak width to search for
                    min_slope = 3 // minimum peak slope to search for, where 1 = 45 deg
                    threshold = threshold || min_width // ignore peaks within <threshold> distance of each other
              Severity: Minor
              Found in app/assets/javascripts/api.js - About 1 hr to fix

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

                  def search
                    id = params[:id]
                    range = params[:fit]
                    range ||= 100
                
                
                Severity: Minor
                Found in app/controllers/match_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 generate_hashed_values has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def generate_hashed_values
                    lines = latest_json_data['lines']
                
                    values = {}
                    counts = {}
                Severity: Minor
                Found in app/models/spectrum.rb - About 1 hr to fix

                  Method save has 34 lines of code (exceeds 25 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 1 hr to fix

                    Method search has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def search
                        id = params[:id]
                        range = params[:fit]
                        range ||= 100
                    
                    
                    Severity: Minor
                    Found in app/controllers/match_controller.rb - About 1 hr to fix

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

                        def new
                          back_to = params[:back_to]
                          # we pass a temp username; it'll be overwritten by the real one in PublicLab.org's response:
                          open_id = 'x'
                          openid_url = URI.decode(open_id)
                      Severity: Minor
                      Found in app/controllers/sessions_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 setSampleRowClickListener has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        setSampleRowClickListener: function() {
                          $('#webcam').click(function(e){
                            var offX, offY;
                            if (!(e.offsetX || e.offsetY)) {
                              offX = e.pageX - $(e.target).offset().left;
                      Severity: Minor
                      Found in app/assets/javascripts/capture.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 find_similar has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def find_similar(range)
                          proc_nil = false
                      
                          if processed_spectrum.nil?
                            spectra = []
                      Severity: Minor
                      Found in app/models/spectrum.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 updateLegend has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        updateLegend: function() {
                          $W.updateLegendTimeout = null;
                      
                          var pos = $W.latestPosition;
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/analyze.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

                      Function getCrossSection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getCrossSection: function(video) {
                          // draw the new data on the top row of pixels of the canvas, overwriting what's there now
                          if ($W.mobile) {
                            // this is only for the deprecated mobile version
                            $W.ctx.scale(3,1)
                      Severity: Minor
                      Found in app/assets/javascripts/capture.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 show has 28 lines of code (exceeds 25 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 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language