Module: Hone

Defined in:
lib/hone.rb,
lib/hone/cli.rb,
lib/hone/config.rb,
lib/hone/finding.rb,
lib/hone/harness.rb,
lib/hone/scanner.rb,
lib/hone/version.rb,
lib/hone/analyzer.rb,
lib/hone/reporter.rb,
lib/hone/correlator.rb,
lib/hone/exit_codes.rb,
lib/hone/method_map.rb,
lib/hone/adapters/base.rb,
lib/hone/patterns/base.rb,
lib/hone/finding_filter.rb,
lib/hone/formatters/tsv.rb,
lib/hone/harness_runner.rb,
lib/hone/profilers/base.rb,
lib/hone/formatters/base.rb,
lib/hone/formatters/json.rb,
lib/hone/patterns/divmod.rb,
lib/hone/formatters/junit.rb,
lib/hone/formatters/sarif.rb,
lib/hone/patterns/uniq_by.rb,
lib/hone/adapters/fasterer.rb,
lib/hone/formatters/github.rb,
lib/hone/harness_generator.rb,
lib/hone/profilers/factory.rb,
lib/hone/profilers/vernier.rb,
lib/hone/patterns/lazy_ivar.rb,
lib/hone/patterns/sort_last.rb,
lib/hone/patterns/times_map.rb,
lib/hone/patterns/gsub_to_tr.rb,
lib/hone/patterns/inject_sum.rb,
lib/hone/patterns/select_map.rb,
lib/hone/patterns/sort_first.rb,
lib/hone/profilers/stackprof.rb,
lib/hone/patterns/kernel_loop.rb,
lib/hone/patterns/map_compact.rb,
lib/hone/patterns/map_flatten.rb,
lib/hone/suggestion_generator.rb,
lib/hone/formatters/filterable.rb,
lib/hone/patterns/dynamic_ivar.rb,
lib/hone/patterns/flatten_once.rb,
lib/hone/patterns/regexp_match.rb,
lib/hone/patterns/reverse_each.rb,
lib/hone/patterns/select_count.rb,
lib/hone/patterns/select_first.rb,
lib/hone/patterns/sort_by_last.rb,
lib/hone/patterns/sort_reverse.rb,
lib/hone/patterns/string_empty.rb,
lib/hone/patterns/array_compact.rb,
lib/hone/patterns/block_to_proc.rb,
lib/hone/patterns/chars_map_ord.rb,
lib/hone/patterns/count_vs_size.rb,
lib/hone/patterns/hash_each_key.rb,
lib/hone/patterns/range_include.rb,
lib/hone/patterns/reverse_first.rb,
lib/hone/patterns/shuffle_first.rb,
lib/hone/patterns/sort_by_first.rb,
lib/hone/patterns/string_shovel.rb,
lib/hone/patterns/string_casecmp.rb,
lib/hone/patterns/yield_vs_block.rb,
lib/hone/patterns/bsearch_vs_find.rb,
lib/hone/patterns/constant_regexp.rb,
lib/hone/patterns/each_with_index.rb,
lib/hone/patterns/hash_each_value.rb,
lib/hone/patterns/hash_merge_bang.rb,
lib/hone/patterns/string_end_with.rb,
lib/hone/patterns/dynamic_ivar_get.rb,
lib/hone/patterns/each_with_object.rb,
lib/hone/patterns/map_select_chain.rb,
lib/hone/profilers/memory_profiler.rb,
lib/hone/patterns/array_include_set.rb,
lib/hone/patterns/chars_to_variable.rb,
lib/hone/patterns/hash_keys_include.rb,
lib/hone/patterns/slice_with_length.rb,
lib/hone/patterns/string_chars_each.rb,
lib/hone/patterns/string_start_with.rb,
lib/hone/patterns/positive_predicate.rb,
lib/hone/adapters/rubocop_performance.rb,
lib/hone/patterns/hash_values_include.rb,
lib/hone/patterns/parallel_assignment.rb,
lib/hone/patterns/taint_tracking_base.rb,
lib/hone/patterns/string_delete_prefix.rb,
lib/hone/patterns/string_delete_suffix.rb,
lib/hone/patterns/string_concat_in_loop.rb,
lib/hone/patterns/redundant_string_chars.rb,
lib/hone/patterns/chars_to_variable_tainted.rb

Defined Under Namespace

Modules: Adapters, ExitCodes, Formatters, Patterns, Profilers Classes: Analyzer, CLI, Config, Correlator, Error, Finding, FindingFilter, Harness, HarnessGenerator, HarnessRunner, MethodMap, Reporter, Scanner, SuggestionGenerator

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Attribute Details

#alloc_percentFloat? (readonly)

Returns Allocation percentage (set by Correlator).

Returns:

  • (Float, nil)

    Allocation percentage (set by Correlator)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#codeString (readonly)

Returns Source code snippet that triggered the finding.

Returns:

  • (String)

    Source code snippet that triggered the finding



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#columnInteger (readonly)

Returns Column number (0-indexed).

Returns:

  • (Integer)

    Column number (0-indexed)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#cpu_percentFloat? (readonly)

Returns CPU percentage from profiler (set by Correlator).

Returns:

  • (Float, nil)

    CPU percentage from profiler (set by Correlator)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#fileString (readonly)

Returns Path to the source file.

Returns:

  • (String)

    Path to the source file



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#lineInteger (readonly)

Returns Line number (1-indexed).

Returns:

  • (Integer)

    Line number (1-indexed)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#messageString (readonly)

Returns Human-readable description of the optimization.

Returns:

  • (String)

    Human-readable description of the optimization



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#method_nameString? (readonly)

Returns Qualified method name (set by Correlator).

Returns:

  • (String, nil)

    Qualified method name (set by Correlator)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#optimization_typeSymbol (readonly)

Returns One of :cpu, :allocation, :jit.

Returns:

  • (Symbol)

    One of :cpu, :allocation, :jit



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#pattern_idSymbol (readonly)

Returns Identifier for the pattern that matched.

Returns:

  • (Symbol)

    Identifier for the pattern that matched



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#prioritySymbol? (readonly)

Returns One of :hot, :warm, :cold, :unknown (set by Correlator).

Returns:

  • (Symbol, nil)

    One of :hot, :warm, :cold, :unknown (set by Correlator)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#sourceSymbol (readonly)

Returns One of :hone, :fasterer, :rubocop.

Returns:

  • (Symbol)

    One of :hone, :fasterer, :rubocop



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end

#speedupString? (readonly)

Returns Expected performance improvement.

Returns:

  • (String, nil)

    Expected performance improvement



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hone/finding.rb', line 45

Finding = Data.define(
  :file,
  :line,
  :column,
  :pattern_id,
  :optimization_type,  # :cpu, :allocation, :jit
  :source,             # :hone, :fasterer, :rubocop
  :message,
  :speedup,            # Optional: "1.5x faster"
  :code,               # Source code snippet
  :method_name,        # Populated by correlator
  :cpu_percent,        # Populated by correlator
  :alloc_percent,      # Populated by correlator (Phase 2)
  :priority            # :hot, :warm, :cold
) do
  def initialize(method_name: nil, cpu_percent: nil, alloc_percent: nil, priority: nil, **kwargs)
    super
  end
end