diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..a673d96 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,17 @@ +Layout/IndentHash: + EnforcedStyle: consistent + +Metrics/MethodLength: + Max: 30 + +Style/BracesAroundHashParameters: + EnforcedStyle: braces + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: consistent_comma + +Style/NegatedIf: + Enabled: false \ No newline at end of file diff --git a/Gemfile b/Gemfile index 09a35bb..10756d4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,5 @@ source('https://rubygems.org') group(:development) do gem('nokogiri') + gem('rubocop', '~> 0.58.2') end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 0926c5b..eec9bb1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,15 +1,33 @@ GEM remote: https://rubygems.org/ specs: + ast (2.4.0) + jaro_winkler (1.5.1) mini_portile2 (2.3.0) nokogiri (1.8.4) mini_portile2 (~> 2.3.0) + parallel (1.12.1) + parser (2.5.1.2) + ast (~> 2.4.0) + powerpack (0.1.2) + rainbow (3.0.0) + rubocop (0.58.2) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.10.0) + unicode-display_width (1.4.0) PLATFORMS ruby DEPENDENCIES nokogiri + rubocop (~> 0.58.2) BUNDLED WITH 1.16.2 diff --git a/run.rb b/run.rb index 0774511..8a4ced5 100644 --- a/run.rb +++ b/run.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'coverage' -require 'base64' +require "coverage" +require "base64" # Is the `fuzz` function defined in the fuzz target? def fuzz_function_exists?(file_path) @@ -11,12 +11,12 @@ def fuzz_function_exists?(file_path) begin method(:fuzz) rescue NameError - writer.putc('0') + writer.putc("0") else - writer.putc('1') + writer.putc("1") end end - reader.getc == '1' + reader.getc == "1" end def start_reporting_process(reader) @@ -36,7 +36,7 @@ def start_reporting_process(reader) # https://github.com/mame/coverage-helpers seen[cov_hash] = encoded_bytes - puts('Encountered new code path with input bytes:') + puts("Encountered new code path with input bytes:") puts("\tbytes: #{encoded_bytes.inspect}") end end @@ -44,8 +44,8 @@ end def start_fuzzing_process(file_path, writer) fork do - STDOUT.reopen('/dev/null') - STDIN.reopen('/dev/null') + STDOUT.reopen("/dev/null") + STDIN.reopen("/dev/null") loop do # TODO: better input generation bytes = Random.new.bytes(10) @@ -85,7 +85,7 @@ end def run if ARGV.length != 1 - STDERR.puts('USAGE: fuzz.rb ') + STDERR.puts("USAGE: fuzz.rb ") exit(1) end file_path = ARGV[0].freeze