ManageIQ/net_app_manageability

View on GitHub
lib/net_app_manageability/ontap_method_map.rb

Summary

Maintainability
C
1 day
Test Coverage

File ontap_method_map.rb has 640 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module NetAppManageability
  module OntapMethodMap
    METHOD_MAP = {
      :aggr_add                                                => "aggr-add",
      :aggr_check_spare_low                                    => "aggr-check-spare-low",
Severity: Major
Found in lib/net_app_manageability/ontap_method_map.rb - About 1 day to fix

    Avoid hard coding large quantities of data in code. Prefer reading the data from an external source.
    Open

        METHOD_MAP = {
          :aggr_add                                                => "aggr-add",
          :aggr_check_spare_low                                    => "aggr-check-spare-low",
          :aggr_create                                             => "aggr-create",
          :aggr_destroy                                            => "aggr-destroy",

    Checks for literals with extremely many entries. This is indicative of configuration or data that may be better extracted somewhere else, like a database, fetched from an API, or read from a non-code file (CSV, JSON, YAML, etc.).

    Example:

    # bad
    # Huge Array literal
    [1, 2, '...', 999_999_999]
    
    # bad
    # Huge Hash literal
    { 1 => 1, 2 => 2, '...' => '...', 999_999_999 => 999_999_999}
    
    # bad
    # Huge Set "literal"
    Set[1, 2, '...', 999_999_999]
    
    # good
    # Reasonably sized Array literal
    [1, 2, '...', 10]
    
    # good
    # Reading huge Array from external data source
    # File.readlines('numbers.txt', chomp: true).map!(&:to_i)
    
    # good
    # Reasonably sized Hash literal
    { 1 => 1, 2 => 2, '...' => '...', 10 => 10}
    
    # good
    # Reading huge Hash from external data source
    CSV.foreach('numbers.csv', headers: true).each_with_object({}) do |row, hash|
      hash[row["key"].to_i] = row["value"].to_i
    end
    
    # good
    # Reasonably sized Set "literal"
    Set[1, 2, '...', 10]
    
    # good
    # Reading huge Set from external data source
    SomeFramework.config_for(:something)[:numbers].to_set

    There are no issues that match your filters.

    Category
    Status