princelab/mspire

View on GitHub
lib/mspire/peaklist.rb

Summary

Maintainability
C
1 day
Test Coverage

Method merge_centroids has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def merge_centroids(peaklists, opts={})
        opts[:return_data] = true if opts[:only_data]

        # Create Mspire::Bin objects
        bins = opts[:bins] ? opts[:bins] : create_bins(peaklists, opts)
Severity: Minor
Found in lib/mspire/peaklist.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

Method merge_centroids has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def merge_centroids(peaklists, opts={})
        opts[:return_data] = true if opts[:only_data]

        # Create Mspire::Bin objects
        bins = opts[:bins] ? opts[:bins] : create_bins(peaklists, opts)
Severity: Minor
Found in lib/mspire/peaklist.rb - About 1 hr to fix

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

        def peak_boundaries(gt=0.0)
          in_peak = false
          prev_y = gt
          prev_prev_y = gt
          peak_inds = []
    Severity: Minor
    Found in lib/mspire/peaklist.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 split_contiguous has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_contiguous(methd=:greedy_y, local_min_indices=nil)
          local_min_indices ||= ((pb=peak_boundaries.first) && pb.shift && pb.pop && pb)
    
          if local_min_indices.size == 0
            self
    Severity: Minor
    Found in lib/mspire/peaklist.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 split_contiguous has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def split_contiguous(methd=:greedy_y, local_min_indices=nil)
          local_min_indices ||= ((pb=peak_boundaries.first) && pb.shift && pb.pop && pb)
    
          if local_min_indices.size == 0
            self
    Severity: Minor
    Found in lib/mspire/peaklist.rb - About 1 hr to fix

      Method peak_boundaries has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def peak_boundaries(gt=0.0)
            in_peak = false
            prev_y = gt
            prev_prev_y = gt
            peak_inds = []
      Severity: Minor
      Found in lib/mspire/peaklist.rb - About 1 hr to fix

        Method create_bins has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_bins(peaklists, opts)
                min, max = min_max_x(peaklists)
        
                divisions = []
                bin_width = opts[:bin_width]
        Severity: Minor
        Found in lib/mspire/peaklist.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 min_max_x has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def min_max_x(peaklists)
                # find the min and max across all spectra
                first_peaklist = peaklists.first
                min = first_peaklist.first.x; max = first_peaklist.last.x
                peaklists.each do |peaklist|
        Severity: Minor
        Found in lib/mspire/peaklist.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

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

            def split(split_multipeaks_mthd=:zero)
              if split_multipeaks_mthd == :zero
                split_on_zeros
              else
                boundaries = peak_boundaries(0.0)
        Severity: Minor
        Found in lib/mspire/peaklist.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

        There are no issues that match your filters.

        Category
        Status