giuse/machine_learning_workbench

View on GitHub

Showing 9 of 443 total issues

Method encode has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def encode vec, type: encoding_type
      case type
      when :most_similar
        simils = similarities vec
        code = simils.max_index
Severity: Major
Found in lib/machine_learning_workbench/compressor/vector_quantization.rb - About 3 hrs to fix

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

        def initialize_distribution mu_init: 0, sigma_init: 1
          @mu = case mu_init
            when Range # initialize with random in range
              raise ArgumentError, "mu_init: `Range` start/end in `Float`s" \
                unless mu_init.first.kind_of?(Float) && mu_init.last.kind_of?(Float)

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

        def encode vec, type: encoding_type
          case type
          when :most_similar
            simils = similarities vec
            code = simils.max_index
    Severity: Minor
    Found in lib/machine_learning_workbench/compressor/vector_quantization.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 sorted_inds_lst has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def sorted_inds_lst
          # Build samples and inds from the list of blocks
          samples_lst, inds_lst = blocks.map do |xnes|
            samples = xnes.standard_normal_samples
            inds = xnes.move_inds(samples)

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

        def sorted_inds
          # Xumo::NArray implements the Box-Muller, but no random seed (yet)
          samples = standard_normal_samples
          # samples = NArray.new([popsize, ndims]).rand_norm(0,1)
          inds = move_inds(samples)

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

        def initialize ndims, obj_fn, opt_type, rseed: nil, mu_init: 0, sigma_init: 1, parallel_fit: false, rescale_popsize: 1, rescale_lrate: 1, utilities: nil, popsize: nil, lrate: nil
          raise ArgumentError, "opt_type: #{opt_type}" unless [:min, :max].include? opt_type
          raise ArgumentError, "obj_fn not callable: #{obj_fn}" unless obj_fn.respond_to? :call
          raise ArgumentError, "utilities only if popsize" if utilities && popsize.nil?
          raise ArgumentError, "wrong sizes" if utilities && utilities.size != popsize

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

        def initialize_distribution mu_init: 0, sigma_init: 1
          @mu = case mu_init
            when Range # initialize with random in range
              raise ArgumentError, "mu_init: `Range` start/end in `Float`s" \
                unless mu_init.first.kind_of?(Float) && mu_init.last.kind_of?(Float)

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

          def initialize_distribution mu_init: 0, sigma_init: 1
            @mu = case mu_init
              when Array
                raise ArgumentError unless mu_init.size == ndims
                NArray[mu_init]

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

          def initialize ncentrs:, dims:, vrange:, lrate:, simil_type: nil, encoding_type: nil, init_centr_vrange: nil, rseed: Random.new_seed
      
            @rng = Random.new rseed # TODO: RNG CURRENTLY NOT USED!!
      
            @dims = Array(dims)
      Severity: Minor
      Found in lib/machine_learning_workbench/compressor/vector_quantization.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

      Severity
      Category
      Status
      Source
      Language