Skip to main content

Scapegoat

Rules#

This is a collection of all the Scapegoat rules created by sonar-scala in the Scapegoat rules repository.

  1. !isEmpty can be replaced with nonEmpty InfoInfo
    com.sksamuel.scapegoat.inspections.collections.NegationIsEmpty
  2. !nonEmpty can be replaced with isEmpty InfoInfo
    com.sksamuel.scapegoat.inspections.collections.NegationNonEmpty
  3. Array equals InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ArrayEquals
  4. Array passed to String.format MajorMajor
    com.sksamuel.scapegoat.inspections.string.ArraysInFormat
  5. Avoid (j to k - 1) InfoInfo
    com.sksamuel.scapegoat.inspections.AvoidToMinusOne
  6. Avoid Traversable.size != 0 MinorMinor
    com.sksamuel.scapegoat.inspections.collections.AvoidSizeNotEqualsZero
  7. Avoid Traversable.size == 0 MinorMinor
    com.sksamuel.scapegoat.inspections.collections.AvoidSizeEqualsZero
  8. Avoid operator overload InfoInfo
    com.sksamuel.scapegoat.inspections.style.AvoidOperatorOverload
  9. Big decimal double constructor MinorMinor
    com.sksamuel.scapegoat.inspections.math.BigDecimalDoubleConstructor
  10. BigDecimal setScale() without rounding mode MinorMinor
    com.sksamuel.scapegoat.inspections.math.BigDecimalScaleWithoutRoundingMode
  11. Bounded by a final type MinorMinor
    com.sksamuel.scapegoat.inspections.inference.BoundedByFinalType
  12. Broken odd check MinorMinor
    com.sksamuel.scapegoat.inspections.math.BrokenOddness
  13. Catch exception MinorMinor
    com.sksamuel.scapegoat.inspections.exception.CatchException
  14. Catch fatal exception MinorMinor
    com.sksamuel.scapegoat.inspections.exception.CatchFatal
  15. Catch throwable MinorMinor
    com.sksamuel.scapegoat.inspections.exception.CatchThrowable
  16. Catching NPE MajorMajor
    com.sksamuel.scapegoat.inspections.exception.CatchNpe
  17. Class name not recommended InfoInfo
    com.sksamuel.scapegoat.inspections.naming.ClassNames
  18. Collection index out of bounds MinorMinor
    com.sksamuel.scapegoat.inspections.collections.CollectionNegativeIndex
  19. Collection naming confusion InfoInfo
    com.sksamuel.scapegoat.inspections.collections.CollectionNamingConfusion
  20. Collection promotion to Any MinorMinor
    com.sksamuel.scapegoat.inspections.collections.CollectionPromotionToAny
  21. Comparing unrelated types MajorMajor
    com.sksamuel.scapegoat.inspections.equality.ComparingUnrelatedTypes
  22. Comparision with self MinorMinor
    com.sksamuel.scapegoat.inspections.equality.ComparisonWithSelf
  23. Comparison to empty list InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ComparisonToEmptyList
  24. Comparison to empty set InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ComparisonToEmptySet
  25. Constant if expression MinorMinor
    com.sksamuel.scapegoat.inspections.unneccesary.ConstantIf
  26. Divide by one MinorMinor
    com.sksamuel.scapegoat.inspections.math.DivideByOne
  27. Double negation InfoInfo
    com.sksamuel.scapegoat.inspections.DoubleNegation
  28. Duplicate import InfoInfo
    com.sksamuel.scapegoat.inspections.imports.DuplicateImport
  29. Duplicated map key MinorMinor
    com.sksamuel.scapegoat.inspections.collections.DuplicateMapKey
  30. Duplicated set value MinorMinor
    com.sksamuel.scapegoat.inspections.collections.DuplicateSetValue
  31. Empty case class InfoInfo
    com.sksamuel.scapegoat.inspections.EmptyCaseClass
  32. Empty catch block MinorMinor
    com.sksamuel.scapegoat.inspections.exception.SwallowedException
  33. Empty for loop MinorMinor
    com.sksamuel.scapegoat.inspections.empty.EmptyFor
  34. Empty if expression MinorMinor
    com.sksamuel.scapegoat.inspections.empty.EmptyIfBlock
  35. Empty interpolated string MajorMajor
    com.sksamuel.scapegoat.inspections.string.EmptyInterpolatedString
  36. Empty method MinorMinor
    com.sksamuel.scapegoat.inspections.empty.EmptyMethod
  37. Empty synchronized block MinorMinor
    com.sksamuel.scapegoat.inspections.empty.EmptySynchronizedBlock
  38. Empty try block MinorMinor
    com.sksamuel.scapegoat.inspections.empty.EmptyTryBlock
  39. Empty while block MinorMinor
    com.sksamuel.scapegoat.inspections.empty.EmptyWhileBlock
  40. Exists simplifiable to contains InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ExistsSimplifiableToContains
  41. Finalizer without super MinorMinor
    com.sksamuel.scapegoat.inspections.unsafe.FinalizerWithoutSuper
  42. Floating type comparison MajorMajor
    com.sksamuel.scapegoat.inspections.equality.ComparingFloatingPointTypes
  43. Illegal format string MajorMajor
    com.sksamuel.scapegoat.inspections.string.IllegalFormatString
  44. Impossible Option.size condition MajorMajor
    com.sksamuel.scapegoat.inspections.option.ImpossibleOptionSizeCondition
  45. Incorrect number of args for format MajorMajor
    com.sksamuel.scapegoat.inspections.string.IncorrectNumberOfArgsToFormat
  46. Incorrectly named exceptions MajorMajor
    com.sksamuel.scapegoat.inspections.exception.IncorrectlyNamedExceptions
  47. Integer mod one MinorMinor
    com.sksamuel.scapegoat.inspections.math.ModOne
  48. Invalid regex InfoInfo
    com.sksamuel.scapegoat.inspections.string.InvalidRegex
  49. Java conversions MinorMinor
    com.sksamuel.scapegoat.inspections.collections.JavaConversionsUse
  50. List append is slow InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ListAppend
  51. List.size is O(n) InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ListSize
  52. Lonely sealed trait MajorMajor
    com.sksamuel.scapegoat.inspections.LonelySealedTrait
  53. Looks like interpolated String MinorMinor
    com.sksamuel.scapegoat.inspections.string.LooksLikeInterpolatedString
  54. Match instead of a partial function InfoInfo
    com.sksamuel.scapegoat.inspections.matching.PartialFunctionInsteadOfMatch
  55. Max parameters InfoInfo
    com.sksamuel.scapegoat.inspections.MaxParameters
  56. Method name not recommended InfoInfo
    com.sksamuel.scapegoat.inspections.naming.MethodNames
  57. Method returning Any MinorMinor
    com.sksamuel.scapegoat.inspections.inference.MethodReturningAny
  58. Missing final modifier on case class InfoInfo
    com.sksamuel.scapegoat.inspections.FinalModifierOnCaseClass
  59. Nan comparison MajorMajor
    com.sksamuel.scapegoat.inspections.math.NanComparison
  60. Noop override InfoInfo
    com.sksamuel.scapegoat.inspections.NoOpOverride
  61. Null assignment MinorMinor
    com.sksamuel.scapegoat.inspections.nulls.NullAssignment
  62. Null parameter MinorMinor
    com.sksamuel.scapegoat.inspections.nulls.NullParameter
  63. Object name not recommended InfoInfo
    com.sksamuel.scapegoat.inspections.naming.ObjectNames
  64. Parameterless methods returns unit MinorMinor
    com.sksamuel.scapegoat.inspections.style.ParameterlessMethodReturnsUnit
  65. Pointless type bounds MinorMinor
    com.sksamuel.scapegoat.inspections.inference.PointlessTypeBounds
  66. Prefer Map.empty InfoInfo
    com.sksamuel.scapegoat.inspections.collections.PreferMapEmpty
  67. Prefer Option.isDefined instead of Option.size MajorMajor
    com.sksamuel.scapegoat.inspections.option.OptionSize
  68. Prefer Seq.empty InfoInfo
    com.sksamuel.scapegoat.inspections.collections.PreferSeqEmpty
  69. Prefer Set.empty InfoInfo
    com.sksamuel.scapegoat.inspections.collections.PreferSetEmpty
  70. Product with Serializable inferred MinorMinor
    com.sksamuel.scapegoat.inspections.inference.ProductWithSerializableInferred
  71. PublicFinalizer InfoInfo
    com.sksamuel.scapegoat.inspections.PublicFinalizer
  72. Redundant final modifier on a method InfoInfo
    com.sksamuel.scapegoat.inspections.RedundantFinalModifierOnMethod
  73. Redundant final modifier on a var InfoInfo
    com.sksamuel.scapegoat.inspections.RedundantFinalModifierOnVar
  74. Redundant finalizer MinorMinor
    com.sksamuel.scapegoat.inspections.unneccesary.RedundantFinalizer
  75. Repeated body of if main and else branch MinorMinor
    com.sksamuel.scapegoat.inspections.controlflow.RepeatedIfElseBody
  76. Repeated case body MinorMinor
    com.sksamuel.scapegoat.inspections.matching.RepeatedCaseBody
  77. Simplify boolean expressions InfoInfo
    com.sksamuel.scapegoat.inspections.style.SimplifyBooleanExpression
  78. String.substring(0) InfoInfo
    com.sksamuel.scapegoat.inspections.string.SubstringZero
  79. Strip margin on regex MajorMajor
    com.sksamuel.scapegoat.inspections.string.StripMarginOnRegex
  80. Suspicious match on class object MinorMinor
    com.sksamuel.scapegoat.inspections.matching.SuspiciousMatchOnClassObject
  81. Swap sort filter InfoInfo
    com.sksamuel.scapegoat.inspections.collections.SwapSortFilter
  82. Type shadowing MinorMinor
    com.sksamuel.scapegoat.inspections.TypeShadowing
  83. Unnecessary conversion MinorMinor
    com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryConversion
  84. Unnecessary if condition. InfoInfo
    com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryIf
  85. Unnecessary return InfoInfo
    com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryReturnUse
  86. Unnecessary reverse InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ReverseFunc
  87. Unreachable catch MinorMinor
    com.sksamuel.scapegoat.inspections.exception.UnreachableCatch
  88. Unsafe contains MajorMajor
    com.sksamuel.scapegoat.inspections.collections.UnsafeContains
  89. Unsafe string contains MajorMajor
    com.sksamuel.scapegoat.inspections.string.UnsafeStringContains
  90. Unused parameter MinorMinor
    com.sksamuel.scapegoat.inspections.unneccesary.UnusedMethodParameter
  91. Use cbrt InfoInfo
    com.sksamuel.scapegoat.inspections.math.UseCbrt
  92. Use expm1 InfoInfo
    com.sksamuel.scapegoat.inspections.math.UseExpM1
  93. Use log10 InfoInfo
    com.sksamuel.scapegoat.inspections.math.UseLog10
  94. Use log1p InfoInfo
    com.sksamuel.scapegoat.inspections.math.UseLog1P
  95. Use of Array.toString MinorMinor
    com.sksamuel.scapegoat.inspections.string.ArraysToString
  96. Use of Either.right or Either.left projection followed by a get MajorMajor
    com.sksamuel.scapegoat.inspections.option.EitherGet
  97. Use of Map.get().getOrElse instead of Map.getOrElse MajorMajor
    com.sksamuel.scapegoat.inspections.collections.MapGetAndGetOrElse
  98. Use of Option.get MajorMajor
    com.sksamuel.scapegoat.inspections.option.OptionGet
  99. Use of Try.get MajorMajor
    com.sksamuel.scapegoat.inspections.unsafe.TryGet
  100. Use of apply method on a non-indexed Seq MinorMinor
    com.sksamuel.scapegoat.inspections.collections.CollectionIndexOnNonIndexedSeq
  101. Use of asInstanceOf MinorMinor
    com.sksamuel.scapegoat.inspections.unsafe.AsInstanceOf
  102. Use of isInstanceOf MinorMinor
    com.sksamuel.scapegoat.inspections.unsafe.IsInstanceOf
  103. Use of unsafe Traversable methods. MajorMajor
    com.sksamuel.scapegoat.inspections.collections.UnsafeTraversableMethods
  104. Use sqrt InfoInfo
    com.sksamuel.scapegoat.inspections.math.UseSqrt
  105. Var could be val MinorMinor
    com.sksamuel.scapegoat.inspections.unneccesary.VarCouldBeVal
  106. Var in closure MinorMinor
    com.sksamuel.scapegoat.inspections.VarClosure
  107. Variable shadowing MinorMinor
    com.sksamuel.scapegoat.inspections.VariableShadowing
  108. While true loop MinorMinor
    com.sksamuel.scapegoat.inspections.controlflow.WhileTrue
  109. Zero numerator MinorMinor
    com.sksamuel.scapegoat.inspections.math.ZeroNumerator
  110. filter().head can throw an exception InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FilterDotHead
  111. filter().headOption instead of find() InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FilterDotHeadOption
  112. filter().isEmpty instead of !exists() InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FilterDotIsEmpty
  113. filter().size() instead of count() InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FilterDotSize
  114. filter(_.isDefined).map(_.get) instead of flatten InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FilterOptionAndGet
  115. find().isDefined() instead of exists() InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FindDotIsDefined
  116. find(x => ) != None instead of exists(x =>) InfoInfo
    com.sksamuel.scapegoat.inspections.collections.FindAndNotEqualsNoneReplaceWithExists
  117. reverse.tail.reverse instead of init InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ReverseTailReverse
  118. reverse.take().reverse instead of takeRight InfoInfo
    com.sksamuel.scapegoat.inspections.collections.ReverseTakeReverse