Class: Factbase::Fuzz

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzz.rb

Overview

Fuzzing generator for Factbase.

Author

Yegor Bugayenko ([email protected])

Author

Philip Belousov ([email protected])

Copyright

Copyright © 2024-2026 Yegor Bugayenko

License

MIT

Constant Summary collapse

LABELS =
['bug', 'enhancement', 'documentation', 'duplicate', 'question', 'good first issue', 'help wanted'].freeze
AUTHORS =
['Noah Williams', 'Mason Jones', 'Rocket Man 🚀', 'Иван Иванович', '黒さん', 'Σωκράτης', 'المنطق سي'].freeze
TITLES =
['Clean Code', 'Adding more elegance', 'Удаление статики', 'Re de Müller-Lyer', '纯代码', '✨✨✨'].freeze
MESSAGES =
[
  'Good point, thanks',
  'This is not an object, it is a data holder!',
  'Why is this method static? Please refactor.',
  'I dont like this name. It is not a noun.',
  'Please add a unit test for this change.',
  'NULL is evil, never use it here.',
  'Pure elegance! Very object-oriented.',
  'Finally, a clean decorator! Good job.',
  'Exquisite! No getters, no setters, just behavior.',
  'This PR makes me happy. It is very elegant.',
  'Исправь кодировку!',
  'デザインが悪い (Poor design)',
  'C’est magnifique! ',
  'Λογική χωρίς ',
  'المنطق سيء للغاية',
  'Este código no es elegante',
  '❤️❤️❤️'
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFuzz

Returns a new instance of Fuzz.



36
37
38
39
40
# File 'lib/fuzz.rb', line 36

def initialize
  @next_num = 0
  @max_comments = 10
  raise 'Not enough messages for fuzzing' if MESSAGES.size < @max_comments
end

Class Method Details

.make(count = 1000) ⇒ Object



42
43
44
45
46
47
# File 'lib/fuzz.rb', line 42

def self.make(count = 1000)
  raise "Count must be positive: #{count}" if count.negative?
  fb = Factbase.new
  Factbase::Fuzz.new.feed(fb, count)
  fb
end

Instance Method Details

#feed(fb, count = 1) ⇒ Object



49
50
51
52
53
54
# File 'lib/fuzz.rb', line 49

def feed(fb, count = 1)
  raise "Count must be positive: #{count}" if count.negative?
  count.times do
    pull_request(fb, @next_num += 1)
  end
end