Class: SixthSense::Analyzers::QualityTestSmells

Inherits:
SixthSense::Analyzer show all
Defined in:
lib/sixth_sense/analyzers/quality_test_smells.rb

Constant Summary collapse

WEIGHTS =
{
  assertion_roulette: 3,
  eager_test: 3,
  mystery_guest: 3,
  sleepy_test: 3,
  general_fixture: 2,
  conditional_logic: 2,
  sensitive_equality: 2,
  empty_or_pending: 2,
  duplicate_assert: 1,
  magic_number: 1
}.freeze

Instance Method Summary collapse

Methods inherited from SixthSense::Analyzer

analyzer_id, axis, inherited, level, reference, references

Instance Method Details

#analyze(test_file, context) ⇒ Object

Paper/book basis: van Deursen et al. 2001, Meszaros 2007, and tsDetect/Peruma et al. 2020 (doi:10.1145/3368089.3417921) define the test-smell families aggregated here.



47
48
49
50
51
52
53
# File 'lib/sixth_sense/analyzers/quality_test_smells.rb', line 47

def analyze(test_file, context)
  findings = test_file.test_cases.flat_map { |test_case| findings_for(test_case, context) }
  findings.reject! { |finding| disabled?(test_file, finding) }
  score = quality_score(test_file, findings, context)

  result(score: score, findings: findings, confidence: :high)
end