cloudamatic/mu

View on GitHub
modules/mu/providers/azure.rb

Summary

Maintainability
D
3 days
Test Coverage

Class Azure has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Azure
      @@is_in_azure = nil
      @@metadata = nil
      @@acct_to_profile_map = nil #WHAT EVEN IS THIS? 
      @@myRegion_var = nil
Severity: Minor
Found in modules/mu/providers/azure.rb - About 6 hrs to fix

    Assignment Branch Condition size for method_missing is too high. [76.95/75]
    Open

              def method_missing(method_sym, *arguments)
                MU.log "Calling #{@parentname}.#{@myname}.#{method_sym.to_s}", MU::DEBUG, details: arguments
                retries = 0
                begin
                  if !arguments.nil? and arguments.size == 1
    Severity: Minor
    Found in modules/mu/providers/azure.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Avoid too many return statements within this method.
    Open

              return nil
    Severity: Major
    Found in modules/mu/providers/azure.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return nil
      Severity: Major
      Found in modules/mu/providers/azure.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return name_only ? name : $MU_CFG['azure'][name]
        Severity: Major
        Found in modules/mu/providers/azure.rb - About 30 mins to fix

          Use =~ in places where the MatchData returned by #match will not be used.
          Open

                    next if m.to_s.match(/=$/)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

          Example:

          # bad
          do_something if str.match(/regex/)
          while regex.match('str')
            do_something
          end
          
          # good
          method(str =~ /regex/)
          return value unless regex =~ 'str'

          Use =~ in places where the MatchData returned by #match will not be used.
          Open

                        if @raw.match(/^\/subscriptions\/#{Regexp.quote(@subscription)}\/providers/)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

          Example:

          # bad
          do_something if str.match(/regex/)
          while regex.match('str')
            do_something
          end
          
          # good
          method(str =~ /regex/)
          return value unless regex =~ 'str'

          Use each_value instead of values.each.
          Open

                  map.values.each { |v|
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for uses of each_key and each_value Hash methods.

          Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

          Example:

          # bad
          hash.keys.each { |k| p k }
          hash.values.each { |v| p v }
          hash.each { |k, _v| p k }
          hash.each { |_k, v| p v }
          
          # good
          hash.each_key { |k| p k }
          hash.each_value { |v| p v }

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.marketplace(model = nil, alt_object: nil, credentials: nil, model_version: "V2015_06_01")
                  require 'azure_mgmt_marketplace_ordering'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Resources").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.keyvault(model = nil, alt_object: nil, credentials: nil, model_version: "V2018_02_14")
                  require 'azure_mgmt_key_vault'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("KeyVault").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.compute(model = nil, alt_object: nil, credentials: nil, model_version: "V2019_03_01")
                  require 'azure_mgmt_compute'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Compute").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.billing(model = nil, alt_object: nil, credentials: nil, model_version: "V2018_03_01_preview")
                  require 'azure_mgmt_billing'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Billing").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.apis(model = nil, alt_object: nil, credentials: nil, model_version: "V2019_01_01")
                  require 'azure_mgmt_api_management'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("ApiManagement").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.containers(model = nil, alt_object: nil, credentials: nil, model_version: "V2019_04_01")
                  require 'azure_mgmt_container_service'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("ContainerService").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.features(model = nil, alt_object: nil, credentials: nil, model_version: "V2015_12_01")
                  require 'azure_mgmt_features'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Features").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.serviceaccts(model = nil, alt_object: nil, credentials: nil, model_version: "V2015_08_31_preview")
                  require 'azure_mgmt_msi'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("ManagedServiceIdentity").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.network(model = nil, alt_object: nil, credentials: nil, model_version: "V2019_02_01")
                  require 'azure_mgmt_network'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Network").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.storage(model = nil, alt_object: nil, credentials: nil, model_version: "V2019_04_01")
                  require 'azure_mgmt_storage'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Storage").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.resources(model = nil, alt_object: nil, credentials: nil, model_version: "V2018_05_01")
                  require 'azure_mgmt_resources'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Resources").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 689..698
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 12 locations. Consider refactoring.
          Open

                def self.subs(model = nil, alt_object: nil, credentials: nil, model_version: "V2015_11_01")
                  require 'azure_mgmt_subscriptions'
          
                  if model and model.is_a?(Symbol)
                    return Object.const_get("Azure").const_get("Subscriptions").const_get("Mgmt").const_get(model_version).const_get("Models").const_get(model)
          Severity: Major
          Found in modules/mu/providers/azure.rb and 11 other locations - About 1 hr to fix
          modules/mu/providers/azure.rb on lines 725..734
          modules/mu/providers/azure.rb on lines 743..752
          modules/mu/providers/azure.rb on lines 761..770
          modules/mu/providers/azure.rb on lines 779..788
          modules/mu/providers/azure.rb on lines 797..806
          modules/mu/providers/azure.rb on lines 815..824
          modules/mu/providers/azure.rb on lines 833..842
          modules/mu/providers/azure.rb on lines 851..860
          modules/mu/providers/azure.rb on lines 869..878
          modules/mu/providers/azure.rb on lines 887..896
          modules/mu/providers/azure.rb on lines 924..933

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                    if !arguments.nil? and arguments.size == 1
                      retval = @api.method(method_sym).call(arguments[0])
                    elsif !arguments.nil? and arguments.size > 0
                      retval = @api.method(method_sym).call(*arguments)
                    else
          Severity: Major
          Found in modules/mu/providers/azure.rb and 2 other locations - About 40 mins to fix
          modules/mu/providers/azure.rb on lines 1100..1106
          modules/mu/providers/google.rb on lines 1258..1264

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                        if !arguments.nil? and arguments.size == 1
                          retval = @myobject.method(method_sym).call(arguments[0])
                        elsif !arguments.nil? and arguments.size > 0
                          retval = @myobject.method(method_sym).call(*arguments)
                        else
          Severity: Major
          Found in modules/mu/providers/azure.rb and 2 other locations - About 40 mins to fix
          modules/mu/providers/azure.rb on lines 1065..1071
          modules/mu/providers/google.rb on lines 1258..1264

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 38.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if !$MU_CFG['azure'] or !$MU_CFG['azure'].is_a?(Hash) or $MU_CFG['azure'].size == 0
                    return @@my_hosted_cfg if @@my_hosted_cfg
          
                    if hosted?
                      @@my_hosted_cfg = hosted_config
          Severity: Minor
          Found in modules/mu/providers/azure.rb and 1 other location - About 35 mins to fix
          modules/mu/providers/google.rb on lines 292..301

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                          MU.log e.message+" calling #{@parentname}.#{@myname}.#{method_sym.to_s}(#{arguments.map { |a| a.to_s }.join(", ")})", MU::DEBUG, details: caller
                          retries += 1
          Severity: Minor
          Found in modules/mu/providers/azure.rb and 1 other location - About 25 mins to fix
          modules/mu/providers/azure.rb on lines 1114..1115

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 31.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                          MU.log e.message+" calling #{@parentname}.#{@myname}.#{method_sym.to_s}(#{arguments.map { |a| a.to_s }.join(", ")})", MU::ERR, details: caller
                          raise e
          Severity: Minor
          Found in modules/mu/providers/azure.rb and 1 other location - About 25 mins to fix
          modules/mu/providers/azure.rb on lines 1110..1111

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 31.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          end at 235, 8 is not aligned with if at 227, 25.
          Open

                  end
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks whether the end keywords are aligned properly.

          Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

          If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

          If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

          If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

          Example: EnforcedStyleAlignWith: keyword (default)

          # bad
          
          variable = if true
              end
          
          # good
          
          variable = if true
                     end

          Example: EnforcedStyleAlignWith: variable

          # bad
          
          variable = if true
              end
          
          # good
          
          variable = if true
          end

          Example: EnforcedStyleAlignWith: startofline

          # bad
          
          variable = if true
              end
          
          # good
          
          puts(if true
          end)

          Redundant use of Object#to_s in interpolation.
          Open

                      MU.log "Calling #{@parentname}.#{@myname}.#{method_sym.to_s}", MU::DEBUG, details: arguments
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for string conversion in string interpolation, which is redundant.

          Example:

          # bad
          
          "result is #{something.to_s}"

          Example:

          # good
          
          "result is #{something}"

          end at 73, 8 is not aligned with if at 67, 13.
          Open

                  end
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks whether the end keywords are aligned properly.

          Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

          If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

          If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

          If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

          Example: EnforcedStyleAlignWith: keyword (default)

          # bad
          
          variable = if true
              end
          
          # good
          
          variable = if true
                     end

          Example: EnforcedStyleAlignWith: variable

          # bad
          
          variable = if true
              end
          
          # good
          
          variable = if true
          end

          Example: EnforcedStyleAlignWith: startofline

          # bad
          
          variable = if true
              end
          
          # good
          
          puts(if true
          end)

          Unused method argument - cloudobj. If it's necessary, use _ or _cloudobj as an argument name to indicate that it won't be used. You can also write as habitat(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.habitat(cloudobj, nolookup: false, deploy: nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Do not suppress exceptions.
          Open

                        rescue JSON::ParserError
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for rescue blocks with no body.

          Example:

          # bad
          
          def some_method
            do_something
          rescue
            # do nothing
          end

          Example:

          # bad
          
          begin
            do_something
          rescue
            # do nothing
          end

          Example:

          # good
          
          def some_method
            do_something
          rescue
            handle_exception
          end

          Example:

          # good
          
          begin
            do_something
          rescue
            handle_exception
          end

          Unused method argument - name. If it's necessary, use _ or _name as an argument name to indicate that it won't be used.
          Open

                def self.writeDeploySecret(deploy, value, name = nil, credentials: nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Prefer JSON.parse over JSON.load.
          Open

                    credfile = JSON.load file
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for the use of JSON class methods which have potential security issues.

          Autocorrect is disabled by default because it's potentially dangerous. If using a stream, like JSON.load(open('file')), it will need to call #read manually, like JSON.parse(open('file').read). If reading single values (rather than proper JSON objects), like JSON.load('false'), it will need to pass the quirks_mode: true option, like JSON.parse('false', quirks_mode: true). Other similar issues may apply.

          Example:

          # always offense
          JSON.load("{}")
          JSON.restore("{}")
          
          # no offense
          JSON.parse("{}")

          Redundant use of Object#to_s in interpolation.
          Open

                        MU.log "Error calling #{@parent.api.class.name}.#{@myname}.#{method_sym.to_s}", MU::DEBUG, details: arguments
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for string conversion in string interpolation, which is redundant.

          Example:

          # bad
          
          "result is #{something.to_s}"

          Example:

          # good
          
          "result is #{something}"

          Unused method argument - nolookup. You can also write as habitat(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.habitat(cloudobj, nolookup: false, deploy: nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Unused method argument - credentials. If it's necessary, use _ or _credentials as an argument name to indicate that it won't be used. You can also write as listHabitats(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.listHabitats(credentials = nil, use_cache: true)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          end at 1128, 18 is not aligned with if at 1123, 24.
          Open

                            end
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks whether the end keywords are aligned properly.

          Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

          If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

          If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

          If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

          Example: EnforcedStyleAlignWith: keyword (default)

          # bad
          
          variable = if true
              end
          
          # good
          
          variable = if true
                     end

          Example: EnforcedStyleAlignWith: variable

          # bad
          
          variable = if true
              end
          
          # good
          
          variable = if true
          end

          Example: EnforcedStyleAlignWith: startofline

          # bad
          
          variable = if true
              end
          
          # good
          
          puts(if true
          end)

          Do not suppress exceptions.
          Open

                      rescue ::MsRestAzure::AzureOperationError
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for rescue blocks with no body.

          Example:

          # bad
          
          def some_method
            do_something
          rescue
            # do nothing
          end

          Example:

          # bad
          
          begin
            do_something
          rescue
            # do nothing
          end

          Example:

          # good
          
          def some_method
            do_something
          rescue
            handle_exception
          end

          Example:

          # good
          
          begin
            do_something
          rescue
            handle_exception
          end

          Do not suppress exceptions.
          Open

                  rescue
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for rescue blocks with no body.

          Example:

          # bad
          
          def some_method
            do_something
          rescue
            # do nothing
          end

          Example:

          # bad
          
          begin
            do_something
          rescue
            # do nothing
          end

          Example:

          # good
          
          def some_method
            do_something
          rescue
            handle_exception
          end

          Example:

          # good
          
          begin
            do_something
          rescue
            handle_exception
          end

          Unused method argument - credentials. If it's necessary, use _ or _credentials as an argument name to indicate that it won't be used. You can also write as adminBucketUrl(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.adminBucketUrl(credentials = nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Unused method argument - alt_object.
          Open

                def self.authorization(model = nil, alt_object: nil, credentials: nil, model_version: "V2015_07_01", endpoint_profile: "Latest")
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Unused method argument - use_cache. You can also write as listHabitats(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.listHabitats(credentials = nil, use_cache: true)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Unused method argument - value. If it's necessary, use _ or _value as an argument name to indicate that it won't be used.
          Open

                def self.writeDeploySecret(deploy, value, name = nil, credentials: nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Unused method argument - deploy. You can also write as habitat(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.habitat(cloudobj, nolookup: false, deploy: nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Redundant use of Object#to_s in interpolation.
          Open

                        raise MuError, "Failed to extract at least name and resource_group fields from #{args.flatten.join(", ").to_s}"
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for string conversion in string interpolation, which is redundant.

          Example:

          # bad
          
          "result is #{something.to_s}"

          Example:

          # good
          
          "result is #{something}"

          Redundant use of Object#to_s in interpolation.
          Open

                          MU.log e.message+" calling #{@parentname}.#{@myname}.#{method_sym.to_s}(#{arguments.map { |a| a.to_s }.join(", ")})", MU::ERR, details: caller
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for string conversion in string interpolation, which is redundant.

          Example:

          # bad
          
          "result is #{something.to_s}"

          Example:

          # good
          
          "result is #{something}"

          Redundant use of Object#to_s in interpolation.
          Open

                          MU.log e.message+" calling #{@parentname}.#{@myname}.#{method_sym.to_s}(#{arguments.map { |a| a.to_s }.join(", ")})", MU::DEBUG, details: caller
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for string conversion in string interpolation, which is redundant.

          Example:

          # bad
          
          "result is #{something.to_s}"

          Example:

          # good
          
          "result is #{something}"

          Unused method argument - credentials. If it's necessary, use _ or _credentials as an argument name to indicate that it won't be used. You can also write as adminBucketName(*) if you want the method to accept any arguments but don't care about them.
          Open

                def self.adminBucketName(credentials = nil)
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for unused method arguments.

          Example:

          # bad
          
          def some_method(used, unused, _unused_but_allowed)
            puts used
          end

          Example:

          # good
          
          def some_method(used, _unused, _unused_but_allowed)
            puts used
          end

          Redundant use of Object#to_s in interpolation.
          Open

                              raise MU::Cloud::Azure::APIError.new err["code"]+": "+err["message"]+" (call was #{@parent.api.class.name}.#{@myname}.#{method_sym.to_s})", details: parsed, silent: true
          Severity: Minor
          Found in modules/mu/providers/azure.rb by rubocop

          This cop checks for string conversion in string interpolation, which is redundant.

          Example:

          # bad
          
          "result is #{something.to_s}"

          Example:

          # good
          
          "result is #{something}"

          There are no issues that match your filters.

          Category
          Status