Skip to content

Commit

Permalink
Merge branch 'master' into 362
Browse files Browse the repository at this point in the history
  • Loading branch information
saeltz authored Jan 17, 2025
2 parents 02cfcf5 + 5dac27e commit 733737d
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 156 deletions.
4 changes: 3 additions & 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.19
- 2.12.20
- 2.13.14
- 2.13.15
- 2.13.16
- 3.3.4
- 3.6.2
steps:
Expand Down Expand Up @@ -57,6 +57,8 @@ jobs:
- uses: codecov/codecov-action@v4
- name: Run Scalafix check
run: sbt fixCheck
- name: Check formatting
run: sbt scalafmtCheckAll
- name: Run Scapegoat
run: |
sbt 'set version := "99.0-SNAPSHOT"; publishLocal'
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ developers := List(
)

scalaVersion := "3.6.2"
crossScalaVersions := Seq("2.12.19", "2.12.20", "2.13.14", "2.13.15", "3.3.4", "3.6.2")
crossScalaVersions := Seq("2.12.19", "2.12.20", "2.13.15", "2.13.16", "3.3.4", "3.6.2")
autoScalaLibrary := false
crossVersion := CrossVersion.full
crossTarget := {
Expand Down Expand Up @@ -118,7 +118,7 @@ libraryDependencies ++= (if (scalaBinaryVersion.value == "3") {
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "test",
compilerPlugin(
"org.scalameta" % "semanticdb-scalac" % "4.12.3" cross CrossVersion.full
"org.scalameta" % "semanticdb-scalac" % "4.12.4" cross CrossVersion.full
)
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class VariableShadowing
tree match {
case Block(_, _) | ClassDef(_, _, _, Template(_, _, _)) | ModuleDef(_, _, Template(_, _, _)) |
Function(_, _) =>
enter(); continue(tree); exit()
enter()
continue(tree)
exit()
case DefDef(_, name, _, vparamss, _, rhs) =>
enter()
// For case classes there's a synthetic constructor (not marked as <synthentic>) which takes
Expand All @@ -40,13 +42,13 @@ class VariableShadowing
vparamss.foreach(_.foreach(inspect))
inspect(rhs)
exit()
case ValDef(_, TermName(name), _, _) =>
case ValDef(_, TermName(name), _, _) if name != "_" =>
if (isDefined(name)) context.warn(tree.pos, self, tree.toString.take(200))
contexts.headOption.foreach(_.append(name.trim))
case Match(_, cases) =>
cases.foreach {
case CaseDef(Bind(name, _), _, _) =>
if (isDefined(name.toString)) context.warn(tree.pos, self, tree.toString.take(200))
case CaseDef(Bind(name, _), _, _) if isDefined(name.toString) =>
context.warn(tree.pos, self, tree.toString.take(200))
case _ => // do nothing
}
continue(tree)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala-3/com/sksamuel/scapegoat/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ScapegoatPhase(var configuration: Configuration, override val inspections:
} else {
if (configuration.verbose) {
runCtx.reporter.report(
Info(s"Running with ${activeInspections.size} active inspections", NoSourcePosition)
Info(s"[scapegoat] Running with ${activeInspections.size} active inspections", NoSourcePosition)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import dotty.tools.dotc.core.Types.TermRef
import dotty.tools.dotc.util.SourcePosition

class AvoidRequire
extends Inspection(
text = "Use of require",
defaultLevel = Levels.Warning,
description = "Use require in code.",
explanation = "Using require throws an untyped Exception."
) {
extends Inspection(
text = "Use of require",
defaultLevel = Levels.Warning,
description = "Use require in code.",
explanation = "Using require throws an untyped Exception."
) {

import tpd.*

Expand All @@ -25,15 +25,15 @@ class AvoidRequire
case Apply(ident: Ident, _) if ident.name.toString == "require" =>
ident.tpe.normalizedPrefix match {
case TermRef(tx, nm: Symbol)
if nm.toString == "object Predef" &&
tx.normalizedPrefix.typeSymbol.name.toString == "<root>" =>
if nm.toString == "object Predef" &&
tx.normalizedPrefix.typeSymbol.name.toString == "<root>" =>
feedback.warn(tree.sourcePos, self, tree.asSnippet)
case x =>
case _ =>
}
case _ => traverseChildren(tree)
}
}
}
traverser.traverse(tree)
}
}
}
Loading

0 comments on commit 733737d

Please sign in to comment.