publiclab/spectral-workbench

View on GitHub

Showing 127 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

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

      notify: function(msg,type,expire) {
        if (expire == null) expire = true
        var id = parseInt(Math.random()*100000)
        $('#notify').html($('#notify').html()+"<div id='notify_"+id+"' class='notify'></div>")
        if (type == "warning") $('#notify_'+id).html("<b>Warning:</b> "+msg).addClass('warning')
    Severity: Major
    Found in app/assets/javascripts/capture.js and 1 other location - About 1 day to fix
    app/assets/javascripts/analyze.js on lines 190..201

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

    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

      notify: function(msg,type,expire) {
        if (expire == null) expire = true
        var id = parseInt(Math.random()*100000)
        $('#alerts').html($('#alerts').html()+"<div id='notify_"+id+"' class='notify'></div>")
        if (type == "warning") $('#notify_'+id).html("<b>Warning:</b> "+msg).addClass('alert warning')
    Severity: Major
    Found in app/assets/javascripts/analyze.js and 1 other location - About 1 day to fix
    app/assets/javascripts/capture.js on lines 727..738

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

    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

    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

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

            if ($W.rotated) {
              style.marginTop = '0px';
              style.borderBottomWidth = "0px"
              style.borderRightWidth = "2px"
              style.height = "240px"
        Severity: Major
        Found in app/assets/javascripts/capture.js and 1 other location - About 6 hrs to fix
        app/assets/javascripts/capture.js on lines 589..604

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

        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

            } else {
              style.marginLeft = '0px';
              style.borderBottomWidth = "2px"
              style.borderRightWidth = "0px"
              style.width = "320px"
        Severity: Major
        Found in app/assets/javascripts/capture.js and 1 other location - About 6 hrs to fix
        app/assets/javascripts/capture.js on lines 574..589

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

        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

        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

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

                        if ($W.baseline != null) {
                          var wavelength = parseInt($W.getWavelength(col))
                          $W.data[0].data.push([wavelength,$W.baseline[wavelength]-intensity/2.55])
                        } else $W.data[0].data.push([parseInt($W.getWavelength(col)),intensity/2.55])
              Severity: Major
              Found in app/assets/javascripts/capture.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/capture.js on lines 311..314

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

              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 ($W.baseline != null) {
                          var wavelength = parseInt($W.getWavelength(col))
                          $W.data[0].data.push([wavelength,$W.baseline[wavelength]-intensity/2.55])
                        } else $W.data[0].data.push([parseInt($W.getWavelength(col)),intensity/2.55])
              Severity: Major
              Found in app/assets/javascripts/capture.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/capture.js on lines 301..304

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

              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

                    if (!(e.offsetX || e.offsetY)) {
                  offX = e.pageX - $(e.target).offset().left;
                  offY = e.pageY - $(e.target).offset().top;
                    } else {
                  offX = e.offsetX;
              Severity: Major
              Found in app/assets/javascripts/analyze.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/capture.js on lines 497..503

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

              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

                    if (!(e.offsetX || e.offsetY)) {
                      offX = e.pageX - $(e.target).offset().left;
                      offY = e.pageY - $(e.target).offset().top;
                    } else {
                      offX = e.offsetX;
              Severity: Major
              Found in app/assets/javascripts/capture.js and 1 other location - About 4 hrs to fix
              app/assets/javascripts/analyze.js on lines 305..311

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

              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

              `` 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

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

                    if ($W.rotated) {
                      if (legacy != true) $('#heightIndicator')[0].style.marginLeft = parseInt($W.width_percent*320)+'px';
                      if (legacy != true) $('#heightIndicatorPrev')[0].style.marginLeft = parseInt($W.width_percent*$('#preview').width())+'px';
                    } else {
                Severity: Major
                Found in app/assets/javascripts/capture.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/capture.js on lines 488..491

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

                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

                    } else {
                      if (legacy != true) $('#heightIndicator')[0].style.marginTop = parseInt($W.height_percent*240)+'px';
                      if (legacy != true) $('#heightIndicatorPrev')[0].style.marginTop = parseInt($W.height_percent*$('#preview').height())+'px';
                    }
                Severity: Major
                Found in app/assets/javascripts/capture.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/capture.js on lines 485..488

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

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

                Severity
                Category
                Status
                Source
                Language