SciRuby/nmatrix

View on GitHub
lib/nmatrix/io/mat5_reader.rb

Summary

Maintainability
D
1 day
Test Coverage

File mat5_reader.rb has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative './mat_reader.rb'

module NMatrix::IO::Matlab

  # Reader (and eventual writer) for a version 5 .mat file.
Severity: Minor
Found in lib/nmatrix/io/mat5_reader.rb - About 4 hrs to fix

    Method read_packed has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_packed(packedio, options)
            flags_class, self.nonzero_max = packedio.read([Element, options]).data
    
            self.matlab_class   = MatReader::MCLASSES[flags_class % 16]
    
    
    Severity: Minor
    Found in lib/nmatrix/io/mat5_reader.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

    Method read_packed has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def read_packed(packedio, options)
            raise(ArgumentError, 'Missing mandatory option :endian.') \
             unless options.has_key?(:endian)
    
            tag = packedio.read([Tag, {:endian => options[:endian]}])
    Severity: Minor
    Found in lib/nmatrix/io/mat5_reader.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

    Method read_packed has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def read_packed(packedio, options)
            flags_class, self.nonzero_max = packedio.read([Element, options]).data
    
            self.matlab_class   = MatReader::MCLASSES[flags_class % 16]
    
    
    Severity: Minor
    Found in lib/nmatrix/io/mat5_reader.rb - About 1 hr to fix

      Method repacked_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def repacked_data(to_dtype = nil)
      
              real_mdtype = self.real_part.tag.data_type
      
              # Figure out what dtype to use based on the MATLAB data-types
      Severity: Minor
      Found in lib/nmatrix/io/mat5_reader.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 read_packed has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def read_packed(packedio, options)
              raise(ArgumentError, 'Missing mandatory option :endian.') \
               unless options.has_key?(:endian)
      
              tag = packedio.read([Tag, {:endian => options[:endian]}])
      Severity: Minor
      Found in lib/nmatrix/io/mat5_reader.rb - About 1 hr to fix

        Method to_nm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def to_nm(dtype = nil)
                # Hardest part is figuring out from_dtype, from_index_dtype, and dtype.
                dtype   ||= guess_dtype_from_mdtype
                from_dtype = MatReader::MDTYPE_TO_DTYPE[self.real_part.tag.data_type]
        
        
        Severity: Minor
        Found in lib/nmatrix/io/mat5_reader.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

        There are no issues that match your filters.

        Category
        Status