Skip to content

Commit

Permalink
Update to Scala 2.13.8 (#615)
Browse files Browse the repository at this point in the history
* Add ScalaFmt dialect

* Add ScalaFmt dialect

* Update Scala to 2.13.8 and SemanticDB to 4.4.32

* Scalafix with new sbt syntax

* Typo
  • Loading branch information
saeltz authored Jan 18, 2022
1 parent 63cd8e6 commit e38d498
Show file tree
Hide file tree
Showing 118 changed files with 398 additions and 282 deletions.
6 changes: 3 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

version = "3.2.2"
runner.dialect = scala213source3
maxColumn = 110
docstrings = JavaDoc
docstrings.style = Asterisk
assumeStandardLibraryStripMargin = true
continuationIndent.defnSite = 2
align {
ifWhileOpenParen = false
tokens.add = [
tokens."+" = [
"<-",
{code = "%", owner = "Term.ApplyInfix"},
{code = "%%", owner = "Term.ApplyInfix"}
Expand Down
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ developers := List(
)

scalaVersion := "2.13.7"
crossScalaVersions := Seq("2.11.12", "2.12.14", "2.12.15", "2.13.6", "2.13.7")
crossScalaVersions := Seq("2.11.12", "2.12.14", "2.12.15", "2.13.7", "2.13.8")
autoScalaLibrary := false
crossVersion := CrossVersion.full
crossTarget := {
Expand Down Expand Up @@ -63,7 +63,7 @@ val scalac11Options = Seq(
"-Ywarn-numeric-widen",
"-Xmax-classfile-name",
"254"
//"-Ywarn-value-discard"
// "-Ywarn-value-discard"
)
scalacOptions := {
val common = Seq(
Expand Down Expand Up @@ -109,7 +109,7 @@ libraryDependencies ++= Seq(
"org.scala-lang"
),
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "test",
"org.scalatest" %% "scalatest" % "3.2.10" % "test",
"org.scalatest" %% "scalatest" % "3.2.10" % "test",
"org.mockito" % "mockito-all" % "1.10.19" % "test",
"joda-time" % "joda-time" % "2.10.13" % "test",
"org.joda" % "joda-convert" % "2.2.2" % "test",
Expand Down Expand Up @@ -140,11 +140,11 @@ assembly / test := {} // do not run tests during assembly
Test / publishArtifact := false

// Scalafix
ThisBuild / scalafixDependencies += "com.nequissimus" %% "sort-imports" % "0.3.1"
addCommandAlias("fix", "all compile:scalafix test:scalafix; fixImports")
addCommandAlias("fixImports", "compile:scalafix SortImports; test:scalafix SortImports")
addCommandAlias("fixCheck", "compile:scalafix --check; test:scalafix --check; fixCheckImports")
addCommandAlias("fixCheckImports", "compile:scalafix --check SortImports; test:scalafix --check SortImports")
ThisBuild / scalafixDependencies += "com.nequissimus" %% "sort-imports" % "0.6.1"
addCommandAlias("fix", "all Compile / scalafix Test / scalafix; fixImports")
addCommandAlias("fixImports", "Compile / scalafix SortImports; Test / scalafix SortImports")
addCommandAlias("fixCheck", "Compile / scalafix --check; Test / scalafix --check; fixCheckImports")
addCommandAlias("fixCheckImports", "Compile / scalafix --check SortImports; Test / scalafix --check SortImports")

// Scalafmt
ThisBuild / scalafmtOnCompile := sys.env.get("GITHUB_ACTIONS").forall(_.toLowerCase == "false")
3 changes: 2 additions & 1 deletion src/main/scala/com/sksamuel/scapegoat/Feedback.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import scala.reflect.internal.util.Position
import scala.tools.nsc.reporters.Reporter

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class Feedback(
reporter: Reporter,
Expand Down
9 changes: 5 additions & 4 deletions src/main/scala/com/sksamuel/scapegoat/Inspection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import scala.reflect.internal.util.Position
import scala.tools.nsc.Global

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
abstract class Inspection(
val text: String,
Expand All @@ -30,8 +31,8 @@ abstract class Inspector(val context: InspectionContext) {
def postTyperTraverser: context.Traverser

/**
* This method is invoked after all phases of the compiler have completed.
* This method can be used to clean up inspections; to report errors after all phases are complete.
* This method is invoked after all phases of the compiler have completed. This method can be used to clean
* up inspections; to report errors after all phases are complete.
*/
def postInspection(): Unit = ()
}
Expand Down Expand Up @@ -103,7 +104,7 @@ final case class InspectionContext(global: Global, feedback: Feedback) {
case tri @ Try(_, _, _) if isSuppressed(tri.symbol) =>
case ClassDef(_, _, _, Template(parents, _, _))
if parents.map(_.tpe.typeSymbol.fullName).contains("scala.reflect.api.TypeCreator") =>
case _ if analyzer.hasMacroExpansionAttachment(tree) => //skip macros as per http://bit.ly/2uS8BrU
case _ if analyzer.hasMacroExpansionAttachment(tree) => // skip macros as per http://bit.ly/2uS8BrU
case _ => inspect(tree)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/com/sksamuel/scapegoat/Inspections.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import com.sksamuel.scapegoat.inspections.unneccesary._
import com.sksamuel.scapegoat.inspections.unsafe._

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
object Inspections extends App {

Expand Down
18 changes: 10 additions & 8 deletions src/main/scala/com/sksamuel/scapegoat/Level.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.sksamuel.scapegoat

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
sealed trait Level

Expand All @@ -15,12 +16,12 @@ object Levels {
case object Error extends Level

/**
* Warnings are reserved for code that has bad semantics.
* This by itself does not necessarily mean the code is buggy, but could mean the developer
* made a mistake or does not fully understand the contructs or best practice.
* Warnings are reserved for code that has bad semantics. This by itself does not necessarily mean the code
* is buggy, but could mean the developer made a mistake or does not fully understand the contructs or best
* practice.
*
* An example is an expression as a statement. While this is perfectly legal, it could indicate
* that the developer meant to assign the result to or otherwise use it.
* An example is an expression as a statement. While this is perfectly legal, it could indicate that the
* developer meant to assign the result to or otherwise use it.
*
* Another example is a constant if. You can do things like if (true) { } if you want, but since the block
* will always evaluate, the if statement perhaps indicates a mistake.
Expand All @@ -30,12 +31,13 @@ object Levels {
/**
* Infos are used for code which is semantically fine, but there exists a more idomatic way of writing it.
*
* An example would be using an if statement to return true or false as the last statement in a block.
* Eg,
* An example would be using an if statement to return true or false as the last statement in a block. Eg,
*
* {{{
* def foo = {
* if (a) true else false
* }
* }}}
*
* Can be re-written as
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import scala.reflect.internal.Flags
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class AnyUse
extends Inspection(
Expand All @@ -17,7 +18,7 @@ class AnyUse

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -5,7 +5,8 @@ import scala.runtime.{RichInt, RichLong}
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class AvoidToMinusOne
extends Inspection(
Expand All @@ -17,7 +18,7 @@ class AvoidToMinusOne

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class DoubleNegation
extends Inspection(
Expand All @@ -15,7 +16,7 @@ class DoubleNegation

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class EmptyCaseClass
extends Inspection(
Expand All @@ -15,7 +16,7 @@ class EmptyCaseClass

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -5,7 +5,8 @@ import scala.collection.mutable
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class LonelySealedTrait
extends Inspection(
Expand Down Expand Up @@ -36,7 +37,7 @@ class LonelySealedTrait
}
}

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 @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class MaxParameters
extends Inspection(
Expand All @@ -16,15 +17,15 @@ class MaxParameters

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

import context.global._

private def count(vparamss: List[List[ValDef]]): Int =
vparamss.foldLeft(0)((a, b) => a + b.size)

private def countExceeds(vparamss: List[List[ValDef]], limit: Int) =
private def countExceeds(vparamss: List[List[ValDef]], limit: Int): Boolean =
count(vparamss) > limit

override def inspect(tree: Tree): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class NoOpOverride
extends Inspection(
Expand All @@ -15,7 +16,7 @@ class NoOpOverride

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class PublicFinalizer
extends Inspection(
Expand All @@ -18,7 +19,7 @@ class PublicFinalizer

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 @@ -5,7 +5,8 @@ import scala.collection.mutable
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class TypeShadowing
extends Inspection(
Expand All @@ -17,7 +18,7 @@ class TypeShadowing

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class VarClosure
extends Inspection(
Expand All @@ -18,7 +19,7 @@ class VarClosure

import context.global._

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

private def capturesVar(tree: Tree): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections.collections
import com.sksamuel.scapegoat._

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class ArrayEquals
extends Inspection(
Expand All @@ -16,7 +17,7 @@ class ArrayEquals

def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
override def postTyperTraverser =
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 @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections.collections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class AvoidSizeEqualsZero
extends Inspection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.sksamuel.scapegoat.inspections.collections
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

/**
* @author Stephen Samuel
* @author
* Stephen Samuel
*/
class AvoidSizeNotEqualsZero
extends Inspection(
Expand Down
Loading

0 comments on commit e38d498

Please sign in to comment.