Skip to content

Commit

Permalink
Fixed a few minor issues in CatchThrowable, NullParameter and UnsafeT…
Browse files Browse the repository at this point in the history
…raversableMethods
  • Loading branch information
t1b00 committed Sep 11, 2024
1 parent 42ca688 commit 66823a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rules/src/main/scala/fix/CatchThrowable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CatchThrowable extends SemanticRule("CatchThrowable") {

private def diag(pos: Position) = Diagnostic(
"",
"Checks for try blocks that catch Throwable..",
"Checks for try blocks that catch Throwable.",
pos,
"Did you intend to catch all throwables? Consider catching a more specific exception class.",
LintSeverity.Warning
Expand Down
2 changes: 1 addition & 1 deletion rules/src/main/scala/fix/NullParameter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NullParameter extends SemanticRule("NullParameter") {

override def fix(implicit doc: SemanticDocument): Patch = {
doc.tree.collect {
case Term.ArgClause(values, _) => values.collect {
case Term.Apply.After_4_6_0(_, Term.ArgClause(values, _)) => values.collect {
case Lit.Null() => Patch.lint(diag(values.head.pos))
case _ => Patch.empty
}
Expand Down
8 changes: 4 additions & 4 deletions rules/src/main/scala/fix/UnsafeTraversableMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class UnsafeTraversableMethods extends SemanticRule("UnsafeTraversableMethods")

override def fix(implicit doc: SemanticDocument): Patch = {
doc.tree.collect {
case Term.Select(qual @ Term.Name(_), Term.Name(str))
case t @ Term.Select(qual @ Term.Name(_), Term.Name(str))
if unsafeMethods.contains(str)
&& Util.inheritsFrom(qual, "scala/collection/Iterable#") => Patch.lint(diag(qual.pos))
case Term.Select(Term.Apply.After_4_6_0(qual @ Term.Name(_), _), Term.Name(str))
&& Util.inheritsFrom(qual, "scala/collection/Iterable#") => Patch.lint(diag(t.pos))
case t @ Term.Select(Term.Apply.After_4_6_0(qual @ Term.Name(_), _), Term.Name(str))
if unsafeMethods.contains(str)
&& Util.inheritsFrom(qual, "scala/collection/Iterable#") => Patch.lint(diag(qual.pos))
&& Util.inheritsFrom(qual, "scala/collection/Iterable#") => Patch.lint(diag(t.pos))
case _ => Patch.empty
}.asPatch
}
Expand Down

0 comments on commit 66823a7

Please sign in to comment.