emonti/pliney

View on GitHub

Showing 6 of 6 total issues

File macho.rb has 463 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'io_helpers'
require_relative 'apple_code_signature'

# Note this implementation only works with little-endian mach-o binaries
# such as ARM and X86. Older PPC mach-o files are big-endian. Support could
Severity: Minor
Found in lib/pliney/macho.rb - About 7 hrs to fix

    Class IPA has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class IPA
            class ZipExtractError < StandardError
            end
    
            SYSTEM_HAS_UNZIP = system("which unzip > /dev/null")
    Severity: Minor
    Found in lib/pliney/ipa.rb - About 4 hrs to fix

      Method each_executable_entry has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              def each_executable_entry
                  each_file_entry do |entry|
                      next if (zipstream = entry.get_input_stream).nil?
                      next if (magicbytes = zipstream.read(4)).nil?
                      next if (magic = magicbytes.unpack("N").first).nil?
      Severity: Minor
      Found in lib/pliney/ipa.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

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

              class LC_SEGMENT_Reader < CommonSegmentReader
                  def parse()
                      super()
                      @vmaddr = @fh.read_uint32le
                      @vmsize = @fh.read_uint32le
      Severity: Minor
      Found in lib/pliney/macho.rb and 1 other location - About 40 mins to fix
      lib/pliney/macho.rb on lines 438..450

      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 37.

      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

              class LC_SEGMENT_64_Reader < CommonSegmentReader
                  def parse()
                      super()
                      @vmaddr = @fh.read_uint64le
                      @vmsize = @fh.read_uint64le
      Severity: Minor
      Found in lib/pliney/macho.rb and 1 other location - About 40 mins to fix
      lib/pliney/macho.rb on lines 422..434

      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 37.

      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

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

              def self.parse(data)
                  obj = data.is_a?(StringStream)? data : StringStream.new(data)
                  magic = obj.read_uint32
                  n=FADEMAGIC[magic]
                  if n.nil? and ((magic >> 16) == 0xFADE)
      Severity: Minor
      Found in lib/pliney/apple_code_signature.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

      Severity
      Category
      Status
      Source
      Language