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]
- Read upRead up
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,
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:
- Read upRead up
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
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?
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)
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:
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
`` has 31 functions (exceeds 20 allowed). Consider refactoring. Open
$W = {
data: null,
baseline: null,
full_data: [],
unflipped_data: [],
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('/')
- Read upRead up
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?
- Read upRead up
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]
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]
- Read upRead up
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 = {
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']
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
- Read upRead up
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,
- Read upRead up
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"
Method create
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def create
@response = {
errors: [],
saved: {}
}
- Read upRead up
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'