ruboto/ruboto

View on GitHub
rakelib/android_api_gen.rb

Summary

Maintainability
D
2 days
Test Coverage

File android_api_gen.rb has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'strscan'
require 'open-uri'
require 'rexml/document'

$stdout.sync = true
Severity: Minor
Found in rakelib/android_api_gen.rb - About 5 hrs to fix

    Method read_class_or_interface has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def read_class_or_interface
        if doc.scan(/\}\s*/) or doc.eos?
          return '}'
        else
          doc.scan(/(public|protected)?([a-z\s]*)\s(class|interface)\s([^\s]+)\s(extends\s([^\s]+)\s)?(implements\s([^\{]+))?\{\s+/)
    Severity: Minor
    Found in rakelib/android_api_gen.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 compile_platforms has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.compile_platforms()
        #Todo: Check to see if there is a newer repository
        doc = REXML::Document.new(open('https://dl-ssl.google.com/android/repository/repository-12.xml'))
        #odoT
    
    
    Severity: Minor
    Found in rakelib/android_api_gen.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 read_platform_from_xml has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def read_platform_from_xml(file)
        doc = StringScanner.new(file)
        until doc.eos?
          doc.scan(/\s*</)
          unless doc.scan(/\/\w+>\s*/)
    Severity: Minor
    Found in rakelib/android_api_gen.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 compile_platforms has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.compile_platforms()
        #Todo: Check to see if there is a newer repository
        doc = REXML::Document.new(open('https://dl-ssl.google.com/android/repository/repository-12.xml'))
        #odoT
    
    
    Severity: Minor
    Found in rakelib/android_api_gen.rb - About 1 hr to fix

      Method read_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def read_field
          visibility = doc.scan(/\w+/)
          doc.scan(/\s+/)
          rest = doc.scan(/.*$\s*/)
          flags = %w(transient final static deprecated volatile) & rest.split(' ')
      Severity: Minor
      Found in rakelib/android_api_gen.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 read_class_or_interface has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def read_class_or_interface
          if doc.scan(/\}\s*/) or doc.eos?
            return '}'
          else
            doc.scan(/(public|protected)?([a-z\s]*)\s(class|interface)\s([^\s]+)\s(extends\s([^\s]+)\s)?(implements\s([^\{]+))?\{\s+/)
      Severity: Minor
      Found in rakelib/android_api_gen.rb - About 1 hr to fix

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

          def read_platform(number)
            @number = number
        
            if File.exist?("apis/#{@number}.txt")
              read_platform_from_txt(IO.read("apis/#{@number}.txt"))
        Severity: Minor
        Found in rakelib/android_api_gen.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 tag_start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def tag_start(api, *args)
            return if args[0] == self.class.name[0..-4].downcase
            if (i = self.class.children_types.index(args[0]))
              # puts "tag_start: #{args.map {|x| x.inspect}.join(', ')}"
              @children[i] << (@current = self.class.children_classes[i].new(api || self, *args))
        Severity: Minor
        Found in rakelib/android_api_gen.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

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

          def initialize(api, *args)
            @children = []
            self.class.children_types.each {|i| @children << []}
        
            @values = args[1] || {}
        Severity: Minor
        Found in rakelib/android_api_gen.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