jordimassaguerpla/gems-status

View on GitHub
lib/gems-status/utils.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

    def Utils.download_license(name, version, gems_url)
      version = version.to_s if version.is_a? Gem::Version
      key = "#{name}-#{version}-#{gems_url.gsub("/", "_").gsub(":", "_")}"
      return @@licenses[key] if @@licenses[key]
      begin
Severity: Minor
Found in lib/gems-status/utils.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 download_emails has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def Utils.download_emails(email_username, email_password, mailing_lists)
      begin
        self.get_emails_from_fs if @@emails.nil?
      rescue Exception => e
        self.log_error "", "There was a problem getting emails from filesystem #{e.message}"
Severity: Minor
Found in lib/gems-status/utils.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 download_emails has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def Utils.download_emails(email_username, email_password, mailing_lists)
      begin
        self.get_emails_from_fs if @@emails.nil?
      rescue Exception => e
        self.log_error "", "There was a problem getting emails from filesystem #{e.message}"
Severity: Minor
Found in lib/gems-status/utils.rb - About 1 hr to fix

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

        def Utils.get_emails_from_fs
          @@emails = {}
          Dir.glob("#{EMAIL_TMP_PATH}/**/*").each do |filename|
            next unless File.file?(filename)
            open(filename, "r") do |file|
    Severity: Minor
    Found in lib/gems-status/utils.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

    Method send_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def Utils.send_email(email_receiver, email_username, email_password, name, mssg)
    Severity: Minor
    Found in lib/gems-status/utils.rb - About 35 mins to fix

      Method download_gem has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def Utils.download_gem(name, version, gems_url)
            gem_uri = URI.parse("#{gems_url}/#{name}-#{version}.gem")
            tmp_path = "tmp/utils/gems/#{gems_url.gsub("/", "_").gsub(":", "_")}/"
            gem_name = "#{name}-#{version}.gem"
            full_path = "#{tmp_path}/#{gem_name}"
      Severity: Minor
      Found in lib/gems-status/utils.rb - About 25 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