ManageIQ/azure-armrest

View on GitHub
lib/azure/armrest/model/base_model.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
99%

Class BaseModel has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

    class BaseModel
      # Initially inherit the exclusion list from parent class or create an empty Set.
      def self.excl_list
        @excl_list ||= superclass.respond_to?(:excl_list, true) ? superclass.send(:excl_list) : Set.new
      end
Severity: Minor
Found in lib/azure/armrest/model/base_model.rb - About 2 hrs to fix

    Method __setobj__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def __setobj__
            excl_list = self.class.send(:excl_list)
            @hashobj.each do |key, value|
              snake = key.to_s.gsub(/\W/, '_').underscore
    
    
    Severity: Minor
    Found in lib/azure/armrest/model/base_model.rb - About 55 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(json, skip_accessors_definition = false)
            # Find the exclusion list for the model of next level (@embed_model)
            # '#' is the separator between levels. Remove attributes
            # before the first separator.
            @child_excl_list = self.class.send(:excl_list).map do |e|
    Severity: Minor
    Found in lib/azure/armrest/model/base_model.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

    Remove unnecessary require statement.
    Open

    require 'pp'

    Checks for unnecessary require statement.

    The following features are unnecessary require statement because they are already loaded. e.g. Ruby 2.2:

    ruby -ve 'p $LOADED_FEATURES.reject { |feature| %r|/| =~ feature }'
    ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-darwin13]
    ["enumerator.so", "rational.so", "complex.so", "thread.rb"]

    Below are the features that each TargetRubyVersion targets.

    * 2.0+ ... `enumerator`
    * 2.1+ ... `thread`
    * 2.2+ ... Add `rational` and `complex` above
    * 2.5+ ... Add `pp` above
    * 2.7+ ... Add `ruby2_keywords` above
    * 3.1+ ... Add `fiber` above
    * 3.2+ ... `set`

    This cop target those features.

    Example:

    # bad
    require 'unloaded_feature'
    require 'thread'
    
    # good
    require 'unloaded_feature'

    There are no issues that match your filters.

    Category
    Status