Showing 20 of 20 total issues

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

      var x = Math.min(ev._x,  tool.x0),
          y = Math.min(ev._y,  tool.y0),
          w = Math.abs(ev._x - tool.x0),
          h = Math.abs(ev._y - tool.y0);
Severity: Major
Found in app/assets/javascripts/snapshot_editor.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/snapshot_editor.js on lines 257..260

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

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

      var x = Math.min(ev._x,  tool.x0),
          y = Math.min(ev._y,  tool.y0),
          w = Math.abs(ev._x - tool.x0),
          h = Math.abs(ev._y - tool.y0);
Severity: Major
Found in app/assets/javascripts/snapshot_editor.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/snapshot_editor.js on lines 179..182

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

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 apply_filters has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_filters
    @scope = filter_scope(@scope) do |s, f|
      s = s.textual(f.title) if f.title.present?
      s = s.where(id: @favourite_ids) if f.props.try(:include?, 'marked')
      s = s.where(organizations: {id: f.organization_id}) if f.organization_id.present?
Severity: Minor
Found in app/services/investigations_filter.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

Function initEditor has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  window.initEditor = function(options) {
    // Find the canvas element.
    canvaso = document.getElementById('imageView');
    if (!canvaso) {
      alert('Error: I cannot find the canvas element!');
Severity: Major
Found in app/assets/javascripts/snapshot_editor.js - About 2 hrs to fix

    Method apply_filters has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def apply_filters
        @scope = filter_scope(@scope) do |s, f|
          s = s.textual(f.title) if f.title.present?
          s = s.without_response if f.props.try(:include?, 'no_answer')
          s = s.where(id: @favourite_ids) if f.props.try(:include?, 'marked')
    Severity: Minor
    Found in app/services/documents_filter.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 rect has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      tools.rect = function () {
        var tool = this;
        this.started = false;
    
        this.mousedown = function (ev) {
    Severity: Minor
    Found in app/assets/javascripts/snapshot_editor.js - About 1 hr to fix

      Function circle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        tools.circle = function () {
          var tool = this;
          this.started = false;
      
          this.mousedown = function (ev) {
      Severity: Minor
      Found in app/assets/javascripts/snapshot_editor.js - About 1 hr to fix

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

            this.mousedown = function (ev) {
              tool.started = true;
              tool.x0 = ev._x;
              tool.y0 = ev._y;
            };
        Severity: Major
        Found in app/assets/javascripts/snapshot_editor.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/snapshot_editor.js on lines 168..172
        app/assets/javascripts/snapshot_editor.js on lines 246..250

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

            this.mousedown = function (ev) {
              tool.started = true;
              tool.x0 = ev._x;
              tool.y0 = ev._y;
            };
        Severity: Major
        Found in app/assets/javascripts/snapshot_editor.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/snapshot_editor.js on lines 168..172
        app/assets/javascripts/snapshot_editor.js on lines 210..214

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

            this.mousedown = function (ev) {
              tool.started = true;
              tool.x0 = ev._x;
              tool.y0 = ev._y;
            };
        Severity: Major
        Found in app/assets/javascripts/snapshot_editor.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/snapshot_editor.js on lines 210..214
        app/assets/javascripts/snapshot_editor.js on lines 246..250

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

            this.mouseup = function (ev) {
              if (tool.started) {
                tool.mousemove(ev);
                tool.started = false;
                img_update();
        Severity: Major
        Found in app/assets/javascripts/snapshot_editor.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/snapshot_editor.js on lines 196..202
        app/assets/javascripts/snapshot_editor.js on lines 232..238

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

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

            this.mouseup = function (ev) {
              if (tool.started) {
                tool.mousemove(ev);
                tool.started = false;
                img_update();
        Severity: Major
        Found in app/assets/javascripts/snapshot_editor.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/snapshot_editor.js on lines 232..238
        app/assets/javascripts/snapshot_editor.js on lines 279..285

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

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

            this.mouseup = function (ev) {
              if (tool.started) {
                tool.mousemove(ev);
                tool.started = false;
                img_update();
        Severity: Major
        Found in app/assets/javascripts/snapshot_editor.js and 2 other locations - About 1 hr to fix
        app/assets/javascripts/snapshot_editor.js on lines 196..202
        app/assets/javascripts/snapshot_editor.js on lines 279..285

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

        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 apply_filters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def apply_filters
            @scope = filter_scope(@scope) do |s, f|
              s = s.textual(f.title) if f.title.present?
              s = s.where(id: @favourite_ids) if f.props.try(:include?, 'marked')
              s = s.where(organizations: {id: f.organization_id}) if f.organization_id.present?
        Severity: Minor
        Found in app/services/investigations_filter.rb - About 1 hr to fix

          Function line has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            tools.line = function () {
              var tool = this;
              this.started = false;
          
              this.mousedown = function (ev) {
          Severity: Minor
          Found in app/assets/javascripts/snapshot_editor.js - About 1 hr to fix

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

              def sort_scope(scope)
                if @column
                  if self.class.sortable_fields.include?(@column)
                    scope.order("#{@column} #{@direction}")
                  elsif block_given?
            Severity: Minor
            Found in app/services/sorter.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 possible_causes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def possible_causes
                if investigation
                  causes = investigation.documents
                  causes = causes.where(["documents.id NOT IN (?)", subtree_ids]) unless new_record?
                  causes.where(["documents.document_date IS NULL OR documents.document_date <= ?", document_date]) if document_date
            Severity: Minor
            Found in app/models/document.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

            Avoid too many return statements within this function.
            Open

                  return;
            Severity: Major
            Found in app/assets/javascripts/snapshot_editor.js - About 30 mins to fix

              Method sort_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def sort_by(column)
                  return 'javascript:;' unless defined?(@sorter)
                  direction = @sorter.direction == 'asc' ? 'desc' : 'asc'
              
                  filter = @filter.try(:filterer).blank? ? nil : @filter.filterer.marshal_dump
              Severity: Minor
              Found in app/helpers/application_helper.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 allowed? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def allowed?
                  return true if @document.nil?
              
                  (snapshots_count >= 1 && attachements_count >= 1) ||
                  (snapshots_count == 0 && attachements_count > 1) ||
              Severity: Minor
              Found in app/services/attached_destroy_policy.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