publiclab/spectral-workbench

View on GitHub

Showing 84 of 127 total issues

Method create has a Cognitive Complexity of 95 (exceeds 5 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: Minor
Found in app/controllers/spectrums_controller.rb - About 1 day 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 capture.js has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//= require graph.js
// window.webcam.getCameraList()
$W = {
  data: null,
  baseline: null,
Severity: Major
Found in app/assets/javascripts/capture.js - About 1 day to fix

    Function getRow has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
    Open

      getRow: function(y) {
        $W.frame += 1
        if ($W.options.context === 'webrtc') {
          var video = $('video')[0];
          // Grab the existing canvas:
    Severity: Minor
    Found in app/assets/javascripts/capture.js - About 1 day 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 spectrum.rb has 476 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rubygems'
    require 'rmagick'
    
    class Spectrum < ActiveRecord::Base
      include ActionView::Helpers::DateHelper
    Severity: Minor
    Found in app/models/spectrum.rb - About 7 hrs to fix

      Class Spectrum has 51 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Spectrum < ActiveRecord::Base
        include ActionView::Helpers::DateHelper
      
        # place this before the has_one :snapshot so it runs before dependent => :destroy
        before_destroy :is_deletable?
      Severity: Major
      Found in app/models/spectrum.rb - About 7 hrs to fix

        File spectrums_controller.rb has 428 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'will_paginate/array'
        class SpectrumsController < ApplicationController
          respond_to :html, :xml, :js, :csv, :json
          # expand this:
          protect_from_forgery only: %i(clone_calibration extract calibrate save)
        Severity: Minor
        Found in app/controllers/spectrums_controller.rb - About 6 hrs to fix

          Function getRow has 113 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getRow: function(y) {
              $W.frame += 1
              if ($W.options.context === 'webrtc') {
                var video = $('video')[0];
                // Grab the existing canvas:
          Severity: Major
          Found in app/assets/javascripts/capture.js - About 4 hrs to fix

            Class SpectrumsController has 34 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class SpectrumsController < ApplicationController
              respond_to :html, :xml, :js, :csv, :json
              # expand this:
              protect_from_forgery only: %i(clone_calibration extract calibrate save)
              # http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html
            Severity: Minor
            Found in app/controllers/spectrums_controller.rb - About 4 hrs to fix

              `` has 31 functions (exceeds 20 allowed). Consider refactoring.
              Open

              $W = {
                data: null,
                baseline: null,
                full_data: [],
                unflipped_data: [],
              Severity: Minor
              Found in app/assets/javascripts/capture.js - About 3 hrs to fix

                Method openid_authentication has a Cognitive Complexity of 25 (exceeds 5 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 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 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

                  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

                    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
                          Severity
                          Category
                          Status
                          Source
                          Language