publiclab/spectral-workbench

View on GitHub

Showing 84 of 127 total issues

Method notify_commenters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def notify_commenters(new_comment, current_user)
    emails = []
    comments.each do |comment|
      emails << comment.email if comment != new_comment && (!current_user || (comment.author != current_user.login)) && comment.author != author
    end
Severity: Minor
Found in app/models/spectra_set.rb - About 45 mins 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

Avoid deeply nested control flow statements.
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 - About 45 mins to fix

    Method notify_commenters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def notify_commenters(new_comment, current_user)
        emails = []
        comments.each do |comment|
          emails << comment.email if comment != new_comment && (!current_user || (comment.author != current_user.login)) && comment.author != author
        end
    Severity: Minor
    Found in app/models/spectrum.rb - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

              if (blue == 255) $W.data[4].data.push([w,100])
    Severity: Major
    Found in app/assets/javascripts/capture.js - About 45 mins to fix

      Function alert_overexposure has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        alert_overexposure: function() {
          console.log('Checking for overexposure');
          var oe = $W.detect_overexposure()
          if (oe.r || oe.g || oe.b) {
            var msg = "<b>Light source too strong</b>; clipping in channels: "
      Severity: Minor
      Found in app/assets/javascripts/capture.js - About 45 mins 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 setup has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          setup: function(min_width,min_height,min_slope,threshold,pixels,wavelengths) {
      Severity: Minor
      Found in app/assets/javascripts/api.js - About 45 mins to fix

        Function setup has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            setup: function(min_width,min_height,min_slope,threshold,pixels,wavelengths) {
        Severity: Minor
        Found in app/assets/javascripts/api.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if (red == 255) $W.data[4].data.push([w,100])
          Severity: Major
          Found in app/assets/javascripts/capture.js - About 45 mins to fix

            Function initialize has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 calibrate has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            $W.calibrate = function(id,x1,w1,x2,w2) {
            Severity: Minor
            Found in app/assets/javascripts/api.js - About 35 mins to fix

              Function excerptCanvas has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                excerptCanvas: function(x1,y1,x2,y2,source) {
              Severity: Minor
              Found in app/assets/javascripts/capture.js - About 35 mins to fix

                Method change_reference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def change_reference(snapshot_id)
                    # only free, un-depended-on tags can do this
                    if snapshot.has_no_dependent_spectra? && !snapshot.has_subsequent_depended_on_snapshots?
                      old_name = name
                      old_name = old_name.split('#')[0] if has_reference?
                Severity: Minor
                Found in app/models/tag.rb - About 35 mins 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 delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def delete
                    @macro = Macro.find params[:id]
                    if logged_in? && (current_user.id == @macro.user_id || current_user.role == 'admin')
                      if @macro.delete
                        flash[:notice] = 'Macro deleted.'
                Severity: Minor
                Found in app/controllers/macros_controller.rb - About 35 mins 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 is_calibrated? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def is_calibrated?
                    if data.nil?
                      false
                    else
                      if tags.collect(&:key).include?('calibrate') || tags.collect(&:key).include?('linearCalibration')
                Severity: Minor
                Found in app/models/spectrum.rb - About 35 mins 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 is_deletable? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def is_deletable?
                    if is_powertag? && needs_snapshot?
                      if snapshot.nil?
                        true
                      elsif snapshot.is_deletable? # includes snapshot.is_latest?
                Severity: Minor
                Found in app/models/tag.rb - About 35 mins 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 alert_overexposure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  alert_overexposure: function() {
                    var oe = $W.detect_overexposure()
                    if (oe['r'] || oe['g'] || oe['b']) {
                      var msg = "Light source is too strong or camera is too sensitive; overexposure in channels: "
                      var channels = []
                Severity: Minor
                Found in app/assets/javascripts/analyze.js - About 35 mins 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 require_login has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def require_login
                    unless logged_in?
                
                      path_info = request.env['PATH_INFO']
                      login_link = "/login?back_to=#{URI.encode(path_info)}"
                Severity: Minor
                Found in app/controllers/application_controller.rb - About 25 mins 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 success has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  success: function (stream) {
                    //console.log('success')
                    if ($W.options.context === 'webrtc') {
                      $('#heightIndicator').show()
                      $('#webcam-msg').hide()
                Severity: Minor
                Found in app/assets/javascripts/capture.js - About 25 mins 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 fork has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def fork(user)
                    new = dup
                    new.author = user.login
                    new.user_id = user.id
                    new.photo = photo
                Severity: Minor
                Found in app/models/spectrum.rb - About 25 mins 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_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def create_key
                    if logged_in? && current_user.role == 'admin'
                      @device = Device.new(
                        name: 'Precalibrated Countertop Spectrometer',
                        user_id: 0,
                Severity: Minor
                Found in app/controllers/device_controller.rb - About 25 mins 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