CalebFenton/dex-oracle

View on GitHub
lib/dex-oracle/plugins/indexed_string_lookup.rb

Summary

Maintainability
A
1 hr
Test Coverage

Avoid parameter lists longer than 5 parameters. [6/5]
Open

    matches.each do |original, _, str_index, class_name, method_signature, out_reg|

This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

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

  def decrypt_strings(method)
    target_to_contexts = {}
    matches = method.body.scan(STRING_DECRYPT)
    @optimizations[:string_lookups] += matches.size if matches
    matches.each do |original, _, str_index, class_name, method_signature, out_reg|
Severity: Major
Found in lib/dex-oracle/plugins/indexed_string_lookup.rb and 2 other locations - About 55 mins to fix
lib/dex-oracle/plugins/indexed_class_lookup.rb on lines 53..65
lib/dex-oracle/plugins/undexguard.rb on lines 101..113

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

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

  def process
    method_to_target_to_contexts = {}
    @methods.each do |method|
      logger.info("Decrypting indexed strings #{method.descriptor}")
      target_to_contexts = {}
Severity: Major
Found in lib/dex-oracle/plugins/indexed_string_lookup.rb and 2 other locations - About 55 mins to fix
lib/dex-oracle/plugins/bitwise_antiskid.rb on lines 29..42
lib/dex-oracle/plugins/string_decryptor.rb on lines 27..40

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

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

Missing magic comment # frozen_string_literal: true.
Open

require_relative '../logging'

This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: when_needed (default)

# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
  # ...
end

# good
# frozen_string_literal: true

module Foo
  # ...
end

Example: EnforcedStyle: always

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Do not use spaces between -> and opening brace in lambda literals
Open

  MODIFIER = -> (_, output, out_reg) { "const-string #{out_reg}, \"#{output.split('').collect { |e| e.inspect[1..-2] }.join}\"" }

This cop checks for spaces between -> and opening parameter brace in lambda literals.

Example: EnforcedStyle: requirenospace (default)

# bad
  a = -> (x, y) { x + y }

  # good
  a = ->(x, y) { x + y }

Example: EnforcedStyle: require_space

# bad
  a = ->(x, y) { x + y }

  # good
  a = -> (x, y) { x + y }

There are no issues that match your filters.

Category
Status