publiclab/spectral-workbench

View on GitHub

Showing 127 of 127 total issues

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

    if ($W.flipped) {
      style.webkitTransform = "scaleX(-1)"
      style.mozTransform = "scaleX(-1)"
      style.oTransform = "scaleX(-1)"
      style.transform = "scaleX(-1)"
Severity: Major
Found in app/assets/javascripts/capture.js and 1 other location - About 1 hr to fix
app/assets/javascripts/capture.js on lines 558..565

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

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

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

      for (var i = 0; i < sURLVariables.length; i++) 
      {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
    Severity: Major
    Found in app/assets/javascripts/basics.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/basics.js on lines 25..32

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

    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

      for (var i = 0; i < sURLVariables.length; i++) 
      {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
    Severity: Major
    Found in app/assets/javascripts/basics.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/basics.js on lines 38..45

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

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

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

                for (row=0;row<$W.sample_height;row++) {
                   green += img.data[((row*(img.width*4)) + (col*4)) + 1]
                }
          Severity: Major
          Found in app/assets/javascripts/capture.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/capture.js on lines 267..269
          app/assets/javascripts/capture.js on lines 277..279

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

          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 3 locations. Consider refactoring.
          Open

                for (row=0;row<$W.sample_height;row++) {
                   red += img.data[((row*(img.width*4)) + (col*4)) + 0]
                }
          Severity: Major
          Found in app/assets/javascripts/capture.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/capture.js on lines 272..274
          app/assets/javascripts/capture.js on lines 277..279

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

          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 3 locations. Consider refactoring.
          Open

                for (row=0;row<$W.sample_height;row++) {
                   blue += img.data[((row*(img.width*4)) + (col*4)) + 2]
                }
          Severity: Major
          Found in app/assets/javascripts/capture.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/capture.js on lines 267..269
          app/assets/javascripts/capture.js on lines 272..274

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

          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

          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

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

                    CSV.generate do |csv|
                      csv << %w(Wavelength Average Red Green Blue)
                      data.each do |datum|
                        w = datum['wavelength'].to_s[0..6]
                        w = 0 if w == ''
                Severity: Major
                Found in app/helpers/spectrums_helper.rb and 1 other location - About 1 hr to fix
                app/helpers/spectrums_helper.rb on lines 23..32

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

                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

                    CSV.generate do |csv|
                      csv << %w(Wavelength Average Red Green Blue)
                      data.each do |datum|
                        w = datum['wavelength'].to_s[0..6]
                        w = 0 if w == ''
                Severity: Major
                Found in app/helpers/spectrums_helper.rb and 1 other location - About 1 hr to fix
                app/helpers/spectrums_helper.rb on lines 7..16

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

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

                  Severity
                  Category
                  Status
                  Source
                  Language