Showing 12 of 20 total issues

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

        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