Class: RSpec::FlakeClassifier::Classify::Classifier
- Inherits:
-
Object
- Object
- RSpec::FlakeClassifier::Classify::Classifier
- Defined in:
- lib/rspec/flake/classifier/classify/classifier.rb
Constant Summary collapse
- RECOMMENDATIONS =
{ "test_order_dependency" => "Isolate shared state and inspect polluter or cleaner examples.", "async_wait" => "Replace sleeps with observable waits or Capybara matchers.", "concurrency" => "Synchronize shared state and make thread lifecycle explicit.", "resource_leak" => "Close leaked resources in example cleanup hooks.", "network" => "Stub external calls with WebMock/VCR and fail on real sockets.", "time" => "Freeze time and cover timezone or date-boundary cases explicitly.", "io" => "Use isolated temp paths and avoid filesystem order assumptions.", "randomness" => "Fix srand or dependency seeds and avoid random production data in assertions.", "floating_point" => "Assert with tolerance instead of exact float equality.", "unordered_collections" => "Use match_array/contain_exactly or compare sets.", "infrastructure" => "Check CI host limits, disk, memory, and scheduler pressure.", "suspected_flaky_deflaker" => "Review recent changes first; this failure did not cover changed lines.", "known_flaky" => "Inspect the stored classification and linked commits." }.freeze
Instance Method Summary collapse
Instance Method Details
#classify(input = nil, **attributes) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rspec/flake/classifier/classify/classifier.rb', line 26 def classify(input = nil, **attributes) context = build_context(input, attributes) labels = detectors.each_with_object([]) do |detector, result| detected = detector.call(context) next unless detected detected.is_a?(Array) ? result.concat(detected.compact) : result << detected end status = labels.empty? ? "unknown" : "flaky" Result.new(status: status, labels: labels, evidence: labels.flat_map(&:evidence)) end |