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

    Checks whether !isEmpty can be replaced with nonEmpty.

    !.isEmpty can be replaced with.nonEmpty to make it easier to reason about.

    com.sksamuel.scapegoat.inspections.collections.NegationIsEmpty
  2. !nonEmpty can be replaced with isEmpty InfoInfo

    Checks whether !nonEmpty can be replaced with isEmpty.

    !.nonEmpty can be replaced with.isEmpty to make it easier to reason about.

    com.sksamuel.scapegoat.inspections.collections.NegationNonEmpty
  3. Array equals InfoInfo

    Checks for comparison of arrays using == which will always return false.

    Array equals is not an equality check. Use a.deep == b.deep or convert to another collection type.

    com.sksamuel.scapegoat.inspections.collections.ArrayEquals
  4. Array passed to String.format MajorMajor

    Checks for arrays passed to String.format.

    An Array passed to String.format might result in an incorrect formatting.

    com.sksamuel.scapegoat.inspections.string.ArraysInFormat
  5. Avoid (j to k - 1) InfoInfo

    Checks for ranges using (j to k - 1).

    A range in the following format (j to k - 1) can be simplified to (j until k).

    com.sksamuel.scapegoat.inspections.AvoidToMinusOne
  6. Avoid Traversable.size != 0 MinorMinor

    Checks for use of Traversable.size.

    .size can be slow for some data structures, prefer .nonEmpty, which is O(1).

    com.sksamuel.scapegoat.inspections.collections.AvoidSizeNotEqualsZero
  7. Avoid Traversable.size == 0 MinorMinor

    Checks for use of Traversable.size.

    Traversable.size can be slow for some data structures, prefer Traversable.isEmpty, which is O(1).

    com.sksamuel.scapegoat.inspections.collections.AvoidSizeEqualsZero
  8. Avoid operator overload InfoInfo

    Checks for symbolic method names.

    Scala style guide advocates against routinely using operators as method names, see http://docs.scala-lang.org/style/naming-conventions.html#symbolic-method-names.

    com.sksamuel.scapegoat.inspections.style.AvoidOperatorOverload
  9. Big decimal double constructor MinorMinor

    Checks for use of BigDecimal(double) which can be unsafe.

    The results of this constructor can be somewhat unpredictable. E.g. writing new BigDecimal(0.1) in Java creates a BigDecimal which is actually equal to 0.1000000000000000055511151231257827021181583404541015625. This is because 0.1 cannot be represented exactly as a double.

    com.sksamuel.scapegoat.inspections.math.BigDecimalDoubleConstructor
  10. BigDecimal setScale() without rounding mode MinorMinor

    Checks for use of setScale() on a BigDecimal without setting the rounding mode can throw an exception.

    When using setScale() on a BigDecimal without setting the rounding mode, this can throw an exception if rounding is required. Did you mean to call setScale(s, RoundingMode.XYZ)?

    com.sksamuel.scapegoat.inspections.math.BigDecimalScaleWithoutRoundingMode
  11. Bounded by a final type MinorMinor

    Checks for types with upper bounds of a final type.

    Pointless type bound. Type parameter can only be a single value.

    com.sksamuel.scapegoat.inspections.inference.BoundedByFinalType
  12. Broken odd check MinorMinor

    Checks for potentially broken odd checks.

    Code that attempts to check for oddness using x % 2 == 1 will fail on negative numbers. Consider using x % 2 != 0

    com.sksamuel.scapegoat.inspections.math.BrokenOddness
  13. Catch exception MinorMinor

    Checks for try blocks that catch exception.

    Did you intend to catch all exceptions? Consider catching a more specific exception class.

    com.sksamuel.scapegoat.inspections.exception.CatchException
  14. Catch fatal exception MinorMinor

    Checks for try blocks that catch fatal exceptions: VirtualMachineError, ThreadDeath, InterruptedException, LinkageError, ControlThrowable.

    Did you intend to catch a fatal exception? Consider using scala.util.control.NonFatal instead.

    com.sksamuel.scapegoat.inspections.exception.CatchFatal
  15. Catch throwable MinorMinor

    Checks for try blocks that catch Throwable.

    Did you intend to catch all throwables? Consider catching a more specific exception class.

    com.sksamuel.scapegoat.inspections.exception.CatchThrowable
  16. Catching NPE MajorMajor

    Checks for try blocks that catch null pointer exceptions.

    Avoid using null at all cost and you shouldn't need to catch NullPointerExceptions. Prefer Option to indicate potentially missing values and use Try to materialize exceptions thrown by any external libraries.

    com.sksamuel.scapegoat.inspections.exception.CatchNpe
  17. Class name not recommended InfoInfo

    Ensures class names adhere to the style guidelines.

    Class names should begin with uppercase letter.

    com.sksamuel.scapegoat.inspections.naming.ClassNames
  18. Collection index out of bounds MinorMinor

    Checks for negative access on a sequence, e.g. list.get(-1).

    Trying to access Seq elements using a negative index will result in an IndexOutOfBoundsException.

    com.sksamuel.scapegoat.inspections.collections.CollectionNegativeIndex
  19. Collection naming confusion InfoInfo

    Checks for variables that are confusingly named.

    E.g. an instance of a Set is confusingly referred to by a variable called/containing list, or the other way around.

    com.sksamuel.scapegoat.inspections.collections.CollectionNamingConfusion
  20. Collection promotion to Any MinorMinor

    Checks for collection operations that promote the collection to Any.

    The :+ (append) operator on collections accepts any argument you give it, which means that you can end up with e.g. SeqAny if your types don't match.

    com.sksamuel.scapegoat.inspections.collections.CollectionPromotionToAny
  21. Comparing unrelated types MajorMajor

    Checks for equality comparisons that cannot succeed.

    In most case comparing unrelated types cannot succeed and it's usually an indication of a bug.

    com.sksamuel.scapegoat.inspections.equality.ComparingUnrelatedTypes
  22. Comparision with self MinorMinor

    Checks for equality checks with itself.

    Comparison with self will always yield true.

    com.sksamuel.scapegoat.inspections.equality.ComparisonWithSelf
  23. Comparison to empty list InfoInfo

    Checks for code like a == List() or a == Nil.

    Prefer use of isEmpty instead of comparison to an empty List.

    com.sksamuel.scapegoat.inspections.collections.ComparisonToEmptyList
  24. Comparison to empty set InfoInfo

    Checks for code like a == Set() or a == Set.empty.

    Prefer use of isEmpty instead of comparison to an empty Set.

    com.sksamuel.scapegoat.inspections.collections.ComparisonToEmptySet
  25. Constant if expression MinorMinor

    Checks for code where the if condition compiles to a constant.

    An if condition which gets compiled to a constant, like e.g. if (1 < 2) or if (false) doesn't add any value and should be avoided.

    com.sksamuel.scapegoat.inspections.unneccesary.ConstantIf
  26. Divide by one MinorMinor

    Checks for division by one.

    Divide by one will always return the original value.

    com.sksamuel.scapegoat.inspections.math.DivideByOne
  27. Double negation InfoInfo

    Checks for code like !(!b).

    Double negation can be removed, e.g. !(!b) it equal to just b.

    com.sksamuel.scapegoat.inspections.DoubleNegation
  28. Duplicate import InfoInfo

    Checks for duplicate import statements.

    Duplicate imports should be removed.

    com.sksamuel.scapegoat.inspections.imports.DuplicateImport
  29. Duplicated map key MinorMinor

    Checks for duplicate key names in Map literals.

    A map key is overwritten by a later entry.

    com.sksamuel.scapegoat.inspections.collections.DuplicateMapKey
  30. Duplicated set value MinorMinor

    Checks for duplicate values in set literals.

    A set value is overwritten by a later entry.

    com.sksamuel.scapegoat.inspections.collections.DuplicateSetValue
  31. Empty case class InfoInfo

    Checks for empty case classes like, e.g. case class Faceman().

    An empty case class can be rewritten as a case object.

    com.sksamuel.scapegoat.inspections.EmptyCaseClass
  32. Empty catch block MinorMinor

    Finds catch blocks that don't handle caught exceptions.

    If you use a try/catch block to deal with an exception, you should handle all of the caught exceptions and if for some reason you're throwing another exception in the result, you should include the original exception as the cause.

    com.sksamuel.scapegoat.inspections.exception.SwallowedException
  33. Empty for loop MinorMinor

    Checks for empty for loops.

    An empty for loop isn't a common practice and in most cases is considered as dead code.

    com.sksamuel.scapegoat.inspections.empty.EmptyFor
  34. Empty if expression MinorMinor

    Checks for empty if blocks.

    An empty if block is considered as dead code.

    com.sksamuel.scapegoat.inspections.empty.EmptyIfBlock
  35. Empty interpolated string MajorMajor

    Looks for interpolated strings that have no arguments.

    String declared as interpolated but has no parameters can be turned into a regular string.

    com.sksamuel.scapegoat.inspections.string.EmptyInterpolatedString
  36. Empty method MinorMinor

    Checks for empty method statements.

    An empty method is considered as dead code.

    com.sksamuel.scapegoat.inspections.empty.EmptyMethod
  37. Empty synchronized block MinorMinor

    Checks for empty synchronized blocks.

    An empty synchronized block is considered as dead code.

    com.sksamuel.scapegoat.inspections.empty.EmptySynchronizedBlock
  38. Empty try block MinorMinor

    Checks for empty try blocks.

    An empty try block is considered as dead code.

    com.sksamuel.scapegoat.inspections.empty.EmptyTryBlock
  39. Empty while block MinorMinor

    Checks for empty while blocks.

    An empty while block is considered as dead code.

    com.sksamuel.scapegoat.inspections.empty.EmptyWhileBlock
  40. Exists simplifiable to contains InfoInfo

    Checks if exists() can be simplified to contains().

    exists(x => x == y) can be replaced with contains(y).

    com.sksamuel.scapegoat.inspections.collections.ExistsSimplifiableToContains
  41. Finalizer without super MinorMinor

    Checks for overridden finalizers that do not call super.

    Finalizers should call super.finalize() to ensure superclasses are able to run their finalization logic.

    com.sksamuel.scapegoat.inspections.unsafe.FinalizerWithoutSuper
  42. Floating type comparison MajorMajor

    Checks for equality checks on floating point types.

    Due to minor rounding errors, it is not advisable to compare floating-point numbers using the == operator. Either use a threshold based comparison, or switch to a BigDecimal.

    com.sksamuel.scapegoat.inspections.equality.ComparingFloatingPointTypes
  43. Illegal format string MajorMajor

    Checks for invalid format strings.

    An unchecked exception will be thrown when a format string contains an illegal syntax or a format specifier that is incompatible with the given arguments.

    com.sksamuel.scapegoat.inspections.string.IllegalFormatString
  44. Impossible Option.size condition MajorMajor

    Checks for code like option.size > 1.

    Option.size > 1 can never be true, did you mean to use Option.nonEmpty instead?

    com.sksamuel.scapegoat.inspections.option.ImpossibleOptionSizeCondition
  45. Incorrect number of args for format MajorMajor

    Checks for wrong number of arguments to String.format.

    The number of arguments passed to String.format doesn't correspond to the number of fields in the format string.

    com.sksamuel.scapegoat.inspections.string.IncorrectNumberOfArgsToFormat
  46. Incorrectly named exceptions MajorMajor

    Checks for exceptions that are not called Exception and vice versa.*

    Class named exception does not derive from Exception / class derived from Exception is not named *Exception.

    com.sksamuel.scapegoat.inspections.exception.IncorrectlyNamedExceptions
  47. Integer mod one MinorMinor

    Checks for expressions like x % 1.

    Any expression x % 1 will always return 0.

    com.sksamuel.scapegoat.inspections.math.ModOne
  48. Invalid regex InfoInfo

    Checks for invalid regex literals.

    Invalid regex literals can fail at compile time with a PatternSyntaxException. This could be caused by e.g. dangling meta characters, or unclosed escape characters, etc.

    com.sksamuel.scapegoat.inspections.string.InvalidRegex
  49. Java conversions MinorMinor

    Checks for use of Java conversions.

    Use of Java conversions can lead to unusual behaviour. It is recommended to use JavaConverters.

    com.sksamuel.scapegoat.inspections.collections.JavaConversionsUse
  50. List append is slow InfoInfo

    Checks for when elements are appended to a list.

    List append is O(n). For large lists, consider using cons (::) or another data structure such as ListBuffer, Vector or a cats.data.Chain (which has constant prepend and append).

    com.sksamuel.scapegoat.inspections.collections.ListAppend
  51. List.size is O(n) InfoInfo

    Checks for use of List.size.

    List.size is O(n). Consider using a different data type with O(1) size lookup such as Vector or an Array.

    com.sksamuel.scapegoat.inspections.collections.ListSize
  52. Lonely sealed trait MajorMajor

    Checks for sealed traits without any classes extending it.

    A sealed trait that is not extended is considered dead code.

    com.sksamuel.scapegoat.inspections.LonelySealedTrait
  53. Looks like interpolated String MinorMinor

    Checks for strings that look like they should be interpolated.

    Did you forget to prefix this string with an s, f or raw to interpolate it?

    com.sksamuel.scapegoat.inspections.string.LooksLikeInterpolatedString
  54. Match instead of a partial function InfoInfo

    Warns when you could use a partial function directly instead of a match block.

    A map match can be replaced with a partial function for greater readability.

    com.sksamuel.scapegoat.inspections.matching.PartialFunctionInsteadOfMatch
  55. Max parameters InfoInfo

    Checks for methods that have over 10 parameters.

    Methods having a large number of parameters are more difficult to reason about, consider refactoring this code.

    com.sksamuel.scapegoat.inspections.MaxParameters
  56. Method name not recommended InfoInfo

    Warns on method names that don't adhere to the Scala style guidelines.

    Methods should be in camelCase style with the first letter lower-case. See http://docs.scala-lang.org/style/naming-conventions.html#methods.

    com.sksamuel.scapegoat.inspections.naming.MethodNames
  57. Method returning Any MinorMinor

    Checks for functions that are defined or inferred to return Any.

    Method returns Any. Consider using a more specialized type.

    com.sksamuel.scapegoat.inspections.inference.MethodReturningAny
  58. Missing final modifier on case class InfoInfo

    Checks for case classes without a final modifier.

    Using case classes without final modifier can lead to surprising breakage.

    com.sksamuel.scapegoat.inspections.FinalModifierOnCaseClass
  59. Nan comparison MajorMajor

    Checks for x == Double.NaN which will always fail.

    NaN comparison will always fail. Use value.isNan instead.

    com.sksamuel.scapegoat.inspections.math.NanComparison
  60. Noop override InfoInfo

    Checks for code that overrides parent method but simply calls super.

    This method is overridden yet only calls super.

    com.sksamuel.scapegoat.inspections.NoOpOverride
  61. Null assignment MinorMinor

    Checks for use of null in assignments.

    Use an Option instead when the value can be empty.

    com.sksamuel.scapegoat.inspections.nulls.NullAssignment
  62. Null parameter MinorMinor

    Checks for use of null in method invocation.

    Use an Option instead when the value can be empty and pass down a None instead.

    com.sksamuel.scapegoat.inspections.nulls.NullParameter
  63. Object name not recommended InfoInfo

    Ensures object names adhere to the Scala style guidelines.

    Object names should only contain alphanumeric characters.

    com.sksamuel.scapegoat.inspections.naming.ObjectNames
  64. Parameterless methods returns unit MinorMinor

    Checks for methods returning Unit that are defined without empty parentheses.

    Methods should be defined with empty parentheses if they have side effects. A method returning Unit must have side effects, therefore you should declare it with ().

    com.sksamuel.scapegoat.inspections.style.ParameterlessMethodReturnsUnit
  65. Pointless type bounds MinorMinor

    Finds type bounds of the form A <: Any or A >: Nothing.

    Type bound resolves to Nothing <: T <: Any. Did you mean to put in other bounds?

    com.sksamuel.scapegoat.inspections.inference.PointlessTypeBounds
  66. Prefer Map.empty InfoInfo

    Checks for use of Map().

    MapK,V allocates an intermediate object. Consider Map.empty which returns a singleton instance without creating a new object.

    com.sksamuel.scapegoat.inspections.collections.PreferMapEmpty
  67. Prefer Option.isDefined instead of Option.size MajorMajor

    Checks for use of Option.size.

    Prefer to use Option.isDefined, Option.isEmpty or Option.nonEmpty instead of Option.size.

    com.sksamuel.scapegoat.inspections.option.OptionSize
  68. Prefer Seq.empty InfoInfo

    Checks for use of Seq().

    SeqT allocates an intermediate object. Consider Seq.empty which returns a singleton instance without creating a new object.

    com.sksamuel.scapegoat.inspections.collections.PreferSeqEmpty
  69. Prefer Set.empty InfoInfo

    Checks for use of Set().

    SetT allocates an intermediate object. Consider Set.empty which returns a singleton instance without creating a new object.

    com.sksamuel.scapegoat.inspections.collections.PreferSetEmpty
  70. Product with Serializable inferred MinorMinor

    Checks for values that have Product with Serializable as their inferred type.

    It is unlikely that Product with Serializable was your target type. This is often an indication of mixing up incompatible types.

    com.sksamuel.scapegoat.inspections.inference.ProductWithSerializableInferred
  71. PublicFinalizer InfoInfo

    Checks for overridden finalizes that are public.

    Public finalizer should be avoided as finalizers should not be programmatically invoked.

    com.sksamuel.scapegoat.inspections.PublicFinalizer
  72. Redundant final modifier on a method InfoInfo

    Checks for redundant final modifiers on methods.

    A final modifier on methods that cannot be overridden is redundant.

    com.sksamuel.scapegoat.inspections.RedundantFinalModifierOnMethod
  73. Redundant final modifier on a var InfoInfo

    Checks for redundant final modifier on vars.

    A final modifier on a var that cannot be overridden is redundant.

    com.sksamuel.scapegoat.inspections.RedundantFinalModifierOnVar
  74. Redundant finalizer MinorMinor

    Checks for empty finalizers.

    An empty finalizer, e.g. override def finalize: Unit = {} is redundant and should be removed.

    com.sksamuel.scapegoat.inspections.unneccesary.RedundantFinalizer
  75. Repeated body of if main and else branch MinorMinor

    Checks for the main branch and the else branch of an if being the same.

    The if statement could be refactored if both branches are the same or start with the same.

    com.sksamuel.scapegoat.inspections.controlflow.RepeatedIfElseBody
  76. Repeated case body MinorMinor

    Checks for case statements which have the same body.

    Case body is repeated. Consider merging pattern clauses together.

    com.sksamuel.scapegoat.inspections.matching.RepeatedCaseBody
  77. Simplify boolean expressions InfoInfo

    Checks for boolean expressions that can be simplified.

    Boolean expressions such as x == false can be re-written as !x.

    com.sksamuel.scapegoat.inspections.style.SimplifyBooleanExpression
  78. String.substring(0) InfoInfo

    Checks for String.substring(0).

    Use of String.substring(0) will always return the same string.

    com.sksamuel.scapegoat.inspections.string.SubstringZero
  79. Strip margin on regex MajorMajor

    Checks for .stripMargin calls on regex strings that contain a pipe.

    Strip margin will strip | from regex - possible corrupted regex.

    com.sksamuel.scapegoat.inspections.string.StripMarginOnRegex
  80. Suspicious match on class object MinorMinor

    Checks for code where matching is taking place on class literals.

    Matching on an companion object of a case class is probably not what you intended.

    com.sksamuel.scapegoat.inspections.matching.SuspiciousMatchOnClassObject
  81. Swap sort filter InfoInfo

    Checks for an inefficient use of filter.sort.

    Filter first and then sort the remaining collection. Swap sort.filter for filter.sort for better performance.

    com.sksamuel.scapegoat.inspections.collections.SwapSortFilter
  82. Type shadowing MinorMinor

    Checks for shadowed type parameters in methods.

    Shadowing type parameters is considered a bad practice and should be avoided.

    com.sksamuel.scapegoat.inspections.TypeShadowing
  83. Unnecessary conversion MinorMinor

    Checks for unnecessary toInt on instances of Int or toString on Strings, etc.

    Calling e.g. toString on a String or toList on a List is completely unnecessary and it's an equivalent to identity.

    com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryConversion
  84. Unnecessary if condition. InfoInfo

    Checks for code like if (expr) true else false.

    If comparison is not needed. Use the condition, e.g. instead of if (a == b) true else false, use a == b or instead of if (a == b) false else true, use !(a == b).

    com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryIf
  85. Unnecessary return InfoInfo

    Checks for use of return keyword in blocks.

    Scala returns the value of the last expression in a block. Use of return here is not an idiomatic Scala.

    com.sksamuel.scapegoat.inspections.unneccesary.UnnecessaryReturnUse
  86. Unnecessary reverse InfoInfo

    Checks for use of reverse followed by head/headOption/iterator/map.

    reverse followed by head, headOption, iterator, or map can be replaced, respectively, with last, lastOption, reverseIterator, or reverseMap.

    com.sksamuel.scapegoat.inspections.collections.ReverseFunc
  87. Unreachable catch MinorMinor

    Checks for catch clauses that cannot be reached.

    One or more cases are unreachable.

    com.sksamuel.scapegoat.inspections.exception.UnreachableCatch
  88. Unsafe contains MajorMajor

    Checks Seq.contains() and Option.contains() for unrelated types.

    contains() accepts arguments af any type, which means you might be checking if your collection contains an element of an unrelated type.

    com.sksamuel.scapegoat.inspections.collections.UnsafeContains
  89. Unsafe string contains MajorMajor

    Checks for String.contains(value) for invalid types.

    String.contains() accepts arguments af any type, which means you might be checking if your string contains an element of an unrelated type.

    com.sksamuel.scapegoat.inspections.string.UnsafeStringContains
  90. Unused parameter MinorMinor

    Checks for unused method parameters.

    Unused constructor or method parameters should be removed.

    com.sksamuel.scapegoat.inspections.unneccesary.UnusedMethodParameter
  91. Use cbrt InfoInfo

    Checks for use of math.pow for calculating math.cbrt.

    Use math.cbrt, which is clearer and more performant than math.pow(x, 1/3).

    com.sksamuel.scapegoat.inspections.math.UseCbrt
  92. Use expm1 InfoInfo

    Checks for use of math.exp(x) - 1 instead of math.expm1(x).

    Use math.expm1(x), which is clearer and more performant than math.exp(x) - 1.

    com.sksamuel.scapegoat.inspections.math.UseExpM1
  93. Use log10 InfoInfo

    Checks for use of math.log(x)/math.log(10) instead of math.log10(x).

    Use math.log10(x), which is clearer and more performant than $math.log(x)/$math.log(10).

    com.sksamuel.scapegoat.inspections.math.UseLog10
  94. Use log1p InfoInfo

    Checks for use of math.log(x + 1) instead of math.log1p(x)

    Use math.log1p(x) is clearer and more performant than $math.log(1 + x).

    com.sksamuel.scapegoat.inspections.math.UseLog1P
  95. Use of Array.toString MinorMinor

    Checks for explicit toString calls on arrays.

    Calling toString on an array does not perform a deep toString.

    com.sksamuel.scapegoat.inspections.string.ArraysToString
  96. Use of Either.right or Either.left projection followed by a get MajorMajor

    Checks for use of .get on Left or Right projection.

    Method .get on a Left and a Right projection in deprecated since 2.13, use Either.getOrElse or Either.swap.getOrElse instead.

    com.sksamuel.scapegoat.inspections.option.EitherGet
  97. Use of Map.get().getOrElse instead of Map.getOrElse MajorMajor

    Checks whether Map.get().getOrElse() can be simplified to Map.getOrElse().

    Map.get(key).getOrElse(value) can be replaced with Map.getOrElse(key, value), which is more concise.

    com.sksamuel.scapegoat.inspections.collections.MapGetAndGetOrElse
  98. Use of Option.get MajorMajor

    Checks for use of Option.get

    Using Option.get defeats the purpose of using Option in the first place. Use the following instead: Option.getOrElse, Option.fold, pattern matching or don't take the value out of the container and map over it to transform it.

    com.sksamuel.scapegoat.inspections.option.OptionGet
  99. Use of Try.get MajorMajor

    Checks for use of Try.get.

    Using Try.get is unsafe because it will throw the underlying exception in case of a Failure. Use the following instead: Try.getOrElse, Try.fold, pattern matching or don't take the value out of the container and map over it to transform it.

    com.sksamuel.scapegoat.inspections.unsafe.TryGet
  100. Use of apply method on a non-indexed Seq MinorMinor

    Checks for indexing on a Seq which is not an IndexedSeq.

    Using an index to access elements of an IndexedSeq may cause performance problems.

    com.sksamuel.scapegoat.inspections.collections.CollectionIndexOnNonIndexedSeq
  101. Use of asInstanceOf MinorMinor

    **

    Use of asInstanceOf is considered a bad practice - consider using pattern matching instead.

    com.sksamuel.scapegoat.inspections.unsafe.AsInstanceOf
  102. Use of isInstanceOf MinorMinor

    Checks for use of isInstanceOf.

    Use of isInstanceOf is considered a bad practice - consider using pattern matching instead.

    com.sksamuel.scapegoat.inspections.unsafe.IsInstanceOf
  103. Use of unsafe Traversable methods. MajorMajor

    Checks for use of unsafe methods on Traversable.

    The following methods on Traversable are considered to be unsafe (head, tail, init, last, reduce, reduceLeft, reduceRight, max, maxBy, min, minBy).

    com.sksamuel.scapegoat.inspections.collections.UnsafeTraversableMethods
  104. Use sqrt InfoInfo

    Checks for use of math.pow for calculating math.sqrt.

    Use math.sqrt, which is clearer and more performant than $math.pow(x, 0.5).

    com.sksamuel.scapegoat.inspections.math.UseSqrt
  105. Var could be val MinorMinor

    Checks for vars that could be declared as vals.

    A variable (var) that is never written to could be turned into a value (val).

    com.sksamuel.scapegoat.inspections.unneccesary.VarCouldBeVal
  106. Var in closure MinorMinor

    Finds closures that reference variables (var).

    Closing over a var can lead to subtle bugs.

    com.sksamuel.scapegoat.inspections.VarClosure
  107. Variable shadowing MinorMinor

    Checks for multiple uses of the variable name in nested scopes.

    Variable shadowing is very useful, but can easily lead to nasty bugs in your code. Shadowed variables can be potentially confusing to other maintainers when the same name is adopted to have a new meaning in a nested scope.

    com.sksamuel.scapegoat.inspections.VariableShadowing
  108. While true loop MinorMinor

    Checks for code that uses a while(true) or do {...} while(true) block.

    A (do) while true loop is unlikely to be meant for production.

    com.sksamuel.scapegoat.inspections.controlflow.WhileTrue
  109. Zero numerator MinorMinor

    Checks for dividing 0 by a number.

    Dividing zero by any number will always return zero, e.g. 0 / x == 0.

    com.sksamuel.scapegoat.inspections.math.ZeroNumerator
  110. filter().head can throw an exception InfoInfo

    Checks for use of filter().head.

    filter().head can throw an exception if the collection is empty - it can be replaced with find() match {...}.

    com.sksamuel.scapegoat.inspections.collections.FilterDotHead
  111. filter().headOption instead of find() InfoInfo

    Checks for use of filter().headOption.

    filter() scans the entire collection, which is unnecessary if you only want to get the first element that satisfies the predicate - filter().headOption can be replaced with find() to potentially avoid scanning the entire collection.

    com.sksamuel.scapegoat.inspections.collections.FilterDotHeadOption
  112. filter().isEmpty instead of !exists() InfoInfo

    Checks for use of filter().isEmpty.

    filter() scans the entire collection, which can potentially be avoided if the element exists in the collection - filter().isEmpty can be replaced with !exists().

    com.sksamuel.scapegoat.inspections.collections.FilterDotIsEmpty
  113. filter().size() instead of count() InfoInfo

    Checks if filter().size can be simplified to count().

    filter().size can be replaced with count(), which is more concise.

    com.sksamuel.scapegoat.inspections.collections.FilterDotSize
  114. filter(_.isDefined).map(_.get) instead of flatten InfoInfo

    Checks whether the expression can be rewritten using flatten.

    filter(.isDefined).map(.get) can be replaced with flatten.

    com.sksamuel.scapegoat.inspections.collections.FilterOptionAndGet
  115. find().isDefined() instead of exists() InfoInfo

    Checks whether find() can be replaced with exists().

    find().isDefined can be replaced with exists(), which is more concise.

    com.sksamuel.scapegoat.inspections.collections.FindDotIsDefined
  116. find(x => ) != None instead of exists(x =>) InfoInfo

    Checks whether find() can be replaced with exists().

    find() != None can be replaced with exists(), which is more concise.

    com.sksamuel.scapegoat.inspections.collections.FindAndNotEqualsNoneReplaceWithExists
  117. reverse.tail.reverse instead of init InfoInfo

    Checks for use of reverse.tail.reverse.

    reverse.tail.reverse can be replaced with init, which is more concise.

    com.sksamuel.scapegoat.inspections.collections.ReverseTailReverse
  118. reverse.take().reverse instead of takeRight InfoInfo

    Checks for use of reverse.take().reverse.

    reverse.take().reverse can be replaced with takeRight, which is more concise.

    com.sksamuel.scapegoat.inspections.collections.ReverseTakeReverse