Skip to content

Commit

Permalink
Support Scala 2.13.12 (#789)
Browse files Browse the repository at this point in the history
* Scala 2.13.12

* Renaming context to ctx to remove ambiguity

* Explicit type declaration for postTyperTraverser

* Declaring explicitly type of Seq[Inspection] in tests

* Fix FeedbackTest

* Exclude UnnecessaryConversion from Scala 2.13.12

---------

Co-authored-by: Grzegorz Olędzki <[email protected]>
  • Loading branch information
saeltz and mccartney authored Sep 18, 2023
1 parent a7d10c0 commit 0703cd5
Show file tree
Hide file tree
Showing 258 changed files with 1,313 additions and 1,403 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
scala:
- 2.12.17
- 2.12.18
- 2.13.10
- 2.13.11
- 2.13.12
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Scapegoat
[![Codecov](https://img.shields.io/codecov/c/github/sksamuel/scapegoat)](https://codecov.io/gh/sksamuel/scapegoat)
[<img src="https://img.shields.io/maven-central/v/com.sksamuel.scapegoat/scalac-scapegoat-plugin_2.11.12.svg?label=latest%20release%20for%202.11.12"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.11.12%22)
[<img src="https://img.shields.io/maven-central/v/com.sksamuel.scapegoat/scalac-scapegoat-plugin_2.12.16.svg?label=latest%20release%20for%202.12.17"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.12.16%22)
[<img src="https://img.shields.io/maven-central/v/com.sksamuel.scapegoat/scalac-scapegoat-plugin_2.13.10.svg?label=latest%20release%20for%202.13.10"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.13.10%22)
[<img src="https://img.shields.io/maven-central/v/com.sksamuel.scapegoat/scalac-scapegoat-plugin_2.13.12.svg?label=latest%20release%20for%202.13.12"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.13.12%22)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)

Scapegoat is a Scala static code analyzer, which is more colloquially known as a code lint tool or linter. Scapegoat works in a similar vein to Java's [FindBugs](http://findbugs.sourceforge.net/) or [checkstyle](http://checkstyle.sourceforge.net/), or Scala's [Scalastyle](https://github.com/scalastyle/scalastyle).
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ developers := List(
)
)

scalaVersion := "2.13.11"
crossScalaVersions := Seq("2.12.17", "2.12.18", "2.13.10", "2.13.11")
scalaVersion := "2.13.12"
crossScalaVersions := Seq("2.12.17", "2.12.18", "2.13.11", "2.13.12")
autoScalaLibrary := false
crossVersion := CrossVersion.full
crossTarget := {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/sksamuel/scapegoat/Inspection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class Inspection(

val self: Inspection = this

def inspector(context: InspectionContext): Inspector
def inspector(ctx: InspectionContext): Inspector

def isEnabled: Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AnyUse
explanation = "Code returning Any is most likely an indication of a programming error."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AvoidToMinusOne
explanation = "A range in the following format (j to k - 1) can be simplified to (j until k)."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class BooleanParameter
explanation = "Method has Boolean parameter. Consider splitting into two methods or using a case class."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser = new context.Traverser {
import context.global._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class DoubleNegation
explanation = "Double negation can be removed, e.g. !(!b) it equal to just b."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class EmptyCaseClass
explanation = "An empty case class can be rewritten as a case object."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class FinalModifierOnCaseClass
explanation = "Using case classes without final modifier can lead to surprising breakage."
) {

override def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {

import context.global._

override def postTyperTraverser =
override def postTyperTraverser: context.Traverser =
new context.Traverser {

override def inspect(tree: Tree): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class LonelySealedTrait
explanation = "A sealed trait that is not extended is considered dead code."
) {

override def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {

import context.global._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class MaxParameters
"Methods having a large number of parameters are more difficult to reason about, consider refactoring this code."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class NoOpOverride
explanation = "This method is overridden yet only calls super."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class PublicFinalizer
explanation = "Public finalizer should be avoided as finalizers should not be programmatically invoked."
) {

override def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {

import context.global._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class RedundantFinalModifierOnMethod
explanation = "A final modifier on methods that cannot be overridden is redundant."
) {

override def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {

import context.global._
import definitions._

override def postTyperTraverser =
override def postTyperTraverser: context.Traverser =
new context.Traverser {

override def inspect(tree: Tree): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class RedundantFinalModifierOnVar
explanation = "A final modifier on a var that cannot be overridden is redundant."
) {

override def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {

import context.global._

override def postTyperTraverser =
override def postTyperTraverser: context.Traverser =
new context.Traverser {

override def inspect(tree: Tree): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class TypeShadowing
explanation = "Shadowing type parameters is considered a bad practice and should be avoided."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class VarClosure
explanation = "Closing over a var can lead to subtle bugs."
) {

override def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {

import context.global._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class VarUse
"Use of variables is generally discouraged, especially in the context of a shared mutable state. Consider using an immutable state or other referentially transparent alternatives."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

import context.global._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class VariableShadowing
"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."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ArrayEquals
"Array equals is not an equality check. Use a.deep == b.deep or convert to another collection type."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class AvoidSizeEqualsZero
"Traversable.size can be slow for some data structures, prefer Traversable.isEmpty, which is O(1)."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class AvoidSizeNotEqualsZero
explanation = ".size can be slow for some data structures, prefer .nonEmpty, which is O(1)."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class CollectionIndexOnNonIndexedSeq
explanation = "Using an index to access elements of an IndexedSeq may cause performance problems."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class CollectionNamingConfusion
"E.g. an instance of a Set is confusingly referred to by a variable called/containing list, or the other way around."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class CollectionNegativeIndex
"Trying to access Seq elements using a negative index will result in an IndexOutOfBoundsException."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class CollectionPromotionToAny
"The `:+` (append) operator on collections accepts any argument you give it, which means that you can end up with e.g. `Seq[Any]` if your types don't match."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class ComparisonToEmptyList
explanation = "Prefer use of `isEmpty` instead of comparison to an empty List."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class ComparisonToEmptySet
explanation = "Prefer use of `isEmpty` instead of comparison to an empty Set."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class DuplicateMapKey
explanation = "A map key is overwritten by a later entry."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class DuplicateSetValue
explanation = "A set value is overwritten by a later entry."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ExistsSimplifiableToContains
explanation = "`exists(x => x == y)` can be replaced with `contains(y)`."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class FilterDotHead
"`filter().head` can throw an exception if the collection is empty - it can be replaced with `find() match {...}`."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class FilterDotHeadOption
"`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."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class FilterDotIsEmpty
"`filter()` scans the entire collection, which can potentially be avoided if the element exists in the collection - `filter().isEmpty` can be replaced with `!exists()`."
) {

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
override def postTyperTraverser: context.Traverser =
new context.Traverser {

Expand Down
Loading

0 comments on commit 0703cd5

Please sign in to comment.