Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalafmt #431

Merged
merged 1 commit into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
consoleOutput: Boolean,
reporter: Reporter,
Expand Down
3 changes: 2 additions & 1 deletion 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

object Levels {
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/com/sksamuel/scapegoat/ScapegoatConfig.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 ScapegoatConfig extends App {

def inspections: Seq[Inspection] =
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(
text = "Use of Any",
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(
text = "Avoid (j to k - 1)",
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(
text = "Double negation",
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(
text = "Empty case class",
Expand All @@ -21,8 +22,8 @@ class EmptyCaseClass

def accessors(trees: List[Tree]): List[ValDef] = {
trees
.collect {
case v: ValDef => v
.collect { case v: ValDef =>
v
}
.filter(_.mods.isCaseAccessor)
}
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(
text = "Lonely sealed trait",
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(
text = "Max parameters",
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(
text = "Noop override",
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(
text = "PublicFinalizer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class RedundantFinalModifierOnMethod
case DefDef(_, nme.CONSTRUCTOR, _, _, _, _) =>
case DefDef(mods, _, _, _, _, _)
if mods.isFinal &&
(tree.symbol.enclClass.isFinal ||
tree.symbol.enclClass.isCase ||
tree.symbol.enclClass.isModuleOrModuleClass ||
tree.symbol.enclClass.isPackageObjectOrClass) =>
(tree.symbol.enclClass.isFinal ||
tree.symbol.enclClass.isCase ||
tree.symbol.enclClass.isModuleOrModuleClass ||
tree.symbol.enclClass.isPackageObjectOrClass) =>
context.warn(tree.pos, self)
case _ => continue(tree)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class RedundantFinalModifierOnVar
tree match {
case ValDef(mods, _, _, _)
if mods.isFinal && mods.isMutable &&
(tree.symbol.enclClass.isFinal ||
tree.symbol.enclClass.isCase ||
tree.symbol.enclClass.isModuleOrModuleClass ||
tree.symbol.enclClass.isPackageObjectOrClass) =>
(tree.symbol.enclClass.isFinal ||
tree.symbol.enclClass.isCase ||
tree.symbol.enclClass.isModuleOrModuleClass ||
tree.symbol.enclClass.isPackageObjectOrClass) =>
context.warn(tree.pos, self)
case _ => continue(tree)
}
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(
text = "Type shadowing",
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(
text = "Var in closure",
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(
text = "Array equals",
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(
text = "Avoid Traversable.size == 0",
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(
text = "Avoid Traversable.size != 0",
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 Josh Rosen */
* @author Josh Rosen
*/
class CollectionIndexOnNonIndexedSeq
extends Inspection(
text = "Use of apply method on a non-indexed Seq",
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 CollectionNamingConfusion
extends Inspection(
text = "Collection naming confusion",
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 CollectionNegativeIndex
extends Inspection(
text = "Collection index out of bounds",
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 ComparisonToEmptyList
extends Inspection(
text = "Comparison to empty list",
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 ComparisonToEmptySet
extends Inspection(
text = "Comparison to empty set",
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 DuplicateMapKey
extends Inspection(
text = "Duplicated map key",
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 DuplicateSetValue
extends Inspection(
text = "Duplicated set value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ExistsSimplifiableToContains
)
)
if isContainsTraversable(lhs) && doesElementTypeMatch(lhs, x)
&& countUsagesOfAVariable(List(subtree), iterationVariable) == 1 =>
&& countUsagesOfAVariable(List(subtree), iterationVariable) == 1 =>
context.warn(tree.pos, self, tree.toString.take(500))
case _ => continue(tree)
}
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 FilterDotHead
extends Inspection(
text = "filter().head can throw an exception",
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 FilterDotHeadOption
extends Inspection(
text = "filter().headOption instead of find()",
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 FilterDotIsEmpty
extends Inspection(
text = "filter().isEmpty instead of !exists()",
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 FilterOptionAndGet
extends Inspection(
text = "filter(_.isDefined).map(_.get) instead of flatten",
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 FindDotIsDefined
extends Inspection(
text = "find().isDefined() instead of exists()",
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 JavaConversionsUse
extends Inspection(
text = "Java conversions",
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 ListAppend
extends Inspection(
text = "List append is slow",
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 ListSize
extends Inspection(
text = "List.size is O(n)",
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 NegationIsEmpty
extends Inspection(
text = "!isEmpty can be replaced with nonEmpty",
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 NegationNonEmpty
extends Inspection(
text = "!nonEmpty can be replaced with isEmpty",
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 NegativeSeqPad
extends Inspection(
text = "Negative seq padTo",
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 PredefIterableIsMutable
extends Inspection(
text = "Default Iterable is mutable",
Expand Down
Loading