princelab/mspire

View on GitHub
lib/mspire/imzml/writer.rb

Summary

Maintainability
D
2 days
Test Coverage

Method write has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def write(mzml_filenames, config={})

      base = config[:combine] || mzml_filenames.first.chomp(File.extname(mzml_filenames.first))
      config[:imzml_filename] = base + ".imzML"
      config[:ibd_filename] = base + ".ibd"
Severity: Major
Found in lib/mspire/imzml/writer.rb - About 3 hrs to fix

    Method write has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def write(mzml_filenames, config={})
    
          base = config[:combine] || mzml_filenames.first.chomp(File.extname(mzml_filenames.first))
          config[:imzml_filename] = base + ".imzML"
          config[:ibd_filename] = base + ".ibd"
    Severity: Minor
    Found in lib/mspire/imzml/writer.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

    File writer.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'nokogiri'
    require 'securerandom'
    require 'cv'
    require 'mspire/mzml'
    require 'mspire/mzml/spectrum'
    Severity: Minor
    Found in lib/mspire/imzml/writer.rb - About 3 hrs to fix

      Method x_y_positions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def x_y_positions(config)
            (scan_pattern, scan_type, scan_direction, scan_sequence, shots_per_pos) = config.values_at(:scan_pattern, :scan_type, :linescan_direction, :linescan_sequence, :shots_per_position).map(&:to_s)
            shots_per_pos = shots_per_pos.to_i
            #puts "EXAMIN ARGS: "
            #p [ scan_pattern, scan_type, scan_direction, scan_sequence, shots_per_pos, shots_per_pos]
      Severity: Minor
      Found in lib/mspire/imzml/writer.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 image_hash_to_cvs has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def image_hash_to_cvs(hash)
            cvs = []
            cvs << case hash[:data_structure].to_sym
            when :processed ; 'IMS:1000031'
            when :continuous ; 'IMS:1000030'
      Severity: Minor
      Found in lib/mspire/imzml/writer.rb - About 1 hr to fix

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

            def create_file_description(source_files, config)
              Mspire::Mzml::FileDescription.new  do |fd|
        
                fd.file_content = Mspire::Mzml::FileContent.new.describe_many!( [
                  'MS:1000579', # MS1 Spectrum
        Severity: Minor
        Found in lib/mspire/imzml/writer.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 write_binary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def write_binary(filename, spectra_iterator, config)
              config = DEFAULTS.merge(config)
              raise ":data_structure must be :continuous or :processed" unless [:processed, :continuous].include?(config[:data_structure])
              (mz_dtype, mz_prec, int_dtype, int_prec) = config.values_at(:mz_data_type, :mz_precision, :intensity_data_type, :intensity_precision)
              mz_prec_in_bytes = mz_prec / 8
        Severity: Minor
        Found in lib/mspire/imzml/writer.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 write_data_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def write_data_array(fh, values, dtype=:float, precision=32)
              pack_code = 
                case dtype
                when :float
                  precision == 64 ? 'E*' : 'e*'
        Severity: Minor
        Found in lib/mspire/imzml/writer.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 experiment_hash_to_cvs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def experiment_hash_to_cvs(hash)
              cvs = { 
                :matrix_solution_concentration => "MS:1000835",
                :matrix_solution => "MS:1000834",
                :solvent => 'IMS:1001211',
        Severity: Minor
        Found in lib/mspire/imzml/writer.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