Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Apr 25, 2024
1 parent 03addca commit 1bc82ba
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion console/src/main/scala/io/appthreat/console/Console.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Console[T <: Project](
def config: ConsoleConfig = _config
def console: Console[T] = this

protected var workspaceManager: WorkspaceManager[T] = _
protected var workspaceManager: WorkspaceManager[T] = scala.compiletime.uninitialized
switchWorkspace(baseDir.path.resolve("workspace").toString)
protected def workspacePathName: String = workspaceManager.getPath

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class ConsoleTests extends AnyWordSpec with Matchers {
)
val numOverlayFilesBefore = console.project.path.resolve("overlays").toFile.list().length
numOverlayFilesBefore shouldBe 0
console._runAnalyzer(defaultOverlayCreators(): _*)
console._runAnalyzer(defaultOverlayCreators()*)
console.project.appliedOverlays shouldBe List(
Base.overlayName,
ControlFlow.overlayName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ExtendedCfgNode(val traversal: Iterator[CfgNode]) extends AnyVal:
sourceTrav: IterableOnce[NodeType],
sourceTravs: IterableOnce[NodeType]*
)(implicit context: EngineContext): Iterator[NodeType] =
val sources = sourceTravsToStartingPoints(sourceTrav +: sourceTravs: _*)
val sources = sourceTravsToStartingPoints(sourceTrav +: sourceTravs*)
val reachedSources =
reachableByInternal(sources).map(_.path.head.node)
reachedSources.cast[NodeType]
Expand All @@ -51,7 +51,7 @@ class ExtendedCfgNode(val traversal: Iterator[CfgNode]) extends AnyVal:
def reachableByFlows[A](sourceTrav: IterableOnce[A], sourceTravs: IterableOnce[A]*)(implicit
context: EngineContext
): Iterator[Path] =
val sources = sourceTravsToStartingPoints(sourceTrav +: sourceTravs: _*)
val sources = sourceTravsToStartingPoints(sourceTrav +: sourceTravs*)
val startingPoints = sources.map(_.startingPoint)
val paths = reachableByInternal(sources).par
.map { result =>
Expand Down Expand Up @@ -79,7 +79,7 @@ class ExtendedCfgNode(val traversal: Iterator[CfgNode]) extends AnyVal:
sourceTravs: Iterator[NodeType]*
)(implicit context: EngineContext): Vector[TableEntry] =
val sources =
SourcesToStartingPoints.sourceTravsToStartingPoints(sourceTrav +: sourceTravs: _*)
SourcesToStartingPoints.sourceTravsToStartingPoints(sourceTrav +: sourceTravs*)
reachableByInternal(sources)

private def removeConsecutiveDuplicates[T](l: Vector[T]): List[T] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DataFlowSolver:
* given by two maps: `in` and `out`. These maps associate all CFG nodes with the set of
* definitions at node entry and node exit respectively.
*/
def calculateMopSolutionForwards[Node, T <: Iterable[_]](problem: DataFlowProblem[Node, T])
def calculateMopSolutionForwards[Node, T <: Iterable[?]](problem: DataFlowProblem[Node, T])
: Solution[Node, T] =
var out: Map[Node, T] = problem.inOutInit.initOut
var in = problem.inOutInit.initIn
Expand Down Expand Up @@ -43,7 +43,7 @@ class DataFlowSolver:
* given by two maps: `in` and `out`. These maps associate all CFG nodes with the set of
* definitions at node entry and node exit respectively.
*/
def calculateMopSolutionBackwards[Node, T <: Iterable[_]](problem: DataFlowProblem[Node, T])
def calculateMopSolutionBackwards[Node, T <: Iterable[?]](problem: DataFlowProblem[Node, T])
: Solution[Node, T] =
var out: Map[Node, T] = problem.inOutInit.initOut
var in = problem.inOutInit.initIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class EagerSourceTypeSolver(
) extends TypeSolver:

private val logger = LoggerFactory.getLogger(this.getClass)
private var parent: TypeSolver = _
private var parent: TypeSolver = scala.compiletime.uninitialized

private val foundTypes: Map[String, SymbolReference[ResolvedReferenceTypeDeclaration]] =
filenames
.flatMap(sourceParser.parseTypesFile)
.flatMap { cu =>
symbolSolver.inject(cu)
cu.findAll(classOf[TypeDeclaration[_]])
cu.findAll(classOf[TypeDeclaration[?]])
.asScala
.map { typeDeclaration =>
val name = typeDeclaration.getFullyQualifiedName.toScala match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import scala.jdk.OptionConverters.RichOptional
class SimpleCombinedTypeSolver extends TypeSolver:

private val logger = LoggerFactory.getLogger(this.getClass)
private var parent: TypeSolver = _
private var parent: TypeSolver = scala.compiletime.uninitialized
// Ideally all types would be cached in the SimpleCombinedTypeSolver to avoid unnecessary unresolved types
// from being cached. The EagerSourceTypeSolver preloads all types, however, so separating caching and
// non-caching solvers avoids caching types twice.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import scala.util.{Failure, Success, Try}

class JarUnpackingTests extends AnyWordSpec with Matchers with BeforeAndAfterAll {

var validCpgs: Map[String, Cpg] = _
var slippyCpg: Cpg = _
var validCpgs: Map[String, Cpg] = scala.compiletime.uninitialized
var slippyCpg: Cpg = scala.compiletime.uninitialized

override protected def beforeAll(): Unit = {
super.beforeAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PythonAstVisitor(

protected val contextStack = new ContextStack()

private var memOpMap: AstNodeToMemoryOperationMap = _
private var memOpMap: AstNodeToMemoryOperationMap = scala.compiletime.uninitialized

private val members = mutable.Map.empty[NewTypeDecl, List[String]]

Expand Down Expand Up @@ -173,7 +173,7 @@ class PythonAstVisitor(
result
end createBuiltinIdentifiers

private def unhandled(node: ast.iast with ast.iattributes): NewNode =
private def unhandled(node: ast.iast & ast.iattributes): NewNode =
val unhandledAsUnknown = true
if unhandledAsUnknown then
nodeBuilder.unknownNode(node.toString, node.getClass.getName, lineAndColOf(node))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.nio.charset.StandardCharsets
import scala.jdk.CollectionConverters.*

class PyParser:
private var pythonParser: PythonParser = _
private var pythonParser: PythonParser = scala.compiletime.uninitialized

def parse(code: String): iast =
parse(new ByteArrayInputStream(code.getBytes(StandardCharsets.UTF_8)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ end X2CpgConfig
* @param frontend
* the frontend to use for CPG creation
*/
abstract class X2CpgMain[T <: X2CpgConfig[T], X <: X2CpgFrontend[_]](
abstract class X2CpgMain[T <: X2CpgConfig[T], X <: X2CpgFrontend[?]](
val cmdLineParser: OParser[Unit, T],
frontend: X
)(
Expand Down Expand Up @@ -105,7 +105,7 @@ end X2CpgMain

/** Trait that represents a CPG generator, where T is the frontend configuration class.
*/
trait X2CpgFrontend[T <: X2CpgConfig[_]]:
trait X2CpgFrontend[T <: X2CpgConfig[?]]:

/** Create a CPG according to given configuration. Returns CPG wrapped in a `Try`, making it
* possible to detect and inspect exceptions in CPG generation. To be provided by the frontend.
Expand Down Expand Up @@ -244,7 +244,7 @@ object X2Cpg:
/** Apply function `applyPasses` to a newly created CPG. The CPG is wrapped in a `Try` and
* returned. On failure, the CPG is ensured to be closed.
*/
def withNewEmptyCpg[T <: X2CpgConfig[_]](
def withNewEmptyCpg[T <: X2CpgConfig[?]](
outPath: String,
config: T
)(applyPasses: (Cpg, T) => Unit): Try[Cpg] =
Expand All @@ -263,7 +263,7 @@ object X2Cpg:
/** Given a function that receives a configuration and returns an arbitrary result type wrapped
* in a `Try`, evaluate the function, printing errors to the console.
*/
def withErrorsToConsole[T <: X2CpgConfig[_]](config: T)(f: T => Try[?]): Try[?] =
def withErrorsToConsole[T <: X2CpgConfig[?]](config: T)(f: T => Try[?]): Try[?] =
f(config) match
case Failure(exception) =>
exception.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import org.slf4j.{Logger, LoggerFactory}
class MethodDecoratorPass(cpg: Cpg) extends CpgPass(cpg):
import MethodDecoratorPass.logger

private[this] var loggedDeprecatedWarning = false
private[this] var loggedMissingTypeFullName = false
private var loggedDeprecatedWarning = false
private var loggedMissingTypeFullName = false

override def run(dstGraph: DiffGraphBuilder): Unit =
cpg.parameter.foreach { parameterIn =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ class CfgCreator(entryNode: Method, diffGraph: DiffGraphBuilder):
maybeFinallyBodyCfg.headOption.getOrElse(Cfg.empty)
else
Cfg
.from(Seq(tryBodyCfg) ++ catchBodyCfgs ++ maybeFinallyBodyCfg: _*)
.from(Seq(tryBodyCfg) ++ catchBodyCfgs ++ maybeFinallyBodyCfg*)
.copy(
entryNode = tryBodyCfg.entryNode,
edges =
Expand Down Expand Up @@ -600,7 +600,7 @@ class CfgCreator(entryNode: Method, diffGraph: DiffGraphBuilder):
val breakFringe = takeCurrentLevel(bodyCfgs.flatMap(_.breaks)).map((_, AlwaysEdge))

Cfg
.from(conditionCfg :: bodyCfgs: _*)
.from(conditionCfg :: bodyCfgs*)
.copy(
entryNode = conditionCfg.entryNode,
edges = caseEdges ++ conditionCfg.edges ++ bodyCfgs.flatMap(_.edges),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ object XTypeRecovery:

/** Parser options for languages implementing this pass.
*/
def parserOptions[R <: X2CpgConfig[R] with TypeRecoveryParserConfig[R]]: OParser[?, R] =
def parserOptions[R <: X2CpgConfig[R] & TypeRecoveryParserConfig[R]]: OParser[?, R] =
val builder = OParser.builder[R]
import builder.*
OParser.sequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import io.appthreat.x2cpg.X2CpgConfig
/** LanguageFrontend encapsulates the logic that translates the source code directory into CPGs
*/
trait LanguageFrontend {
private var config: Option[X2CpgConfig[_]] = None
private var config: Option[X2CpgConfig[?]] = None

def setConfig(config: X2CpgConfig[_]): Unit = {
def setConfig(config: X2CpgConfig[?]): Unit = {
if (this.config.isDefined) {
throw new RuntimeException("Frontend config may only be set once per test")
}
this.config = Some(config)
}

def getConfig(): Option[X2CpgConfig[_]] = config
def getConfig(): Option[X2CpgConfig[?]] = config

/** A standard file extension for the source code files of the given language. E.g. `.c` for C language
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class TestCpg extends Cpg() with LanguageFrontend {
this
}

def withConfig(config: X2CpgConfig[_]): this.type = {
def withConfig(config: X2CpgConfig[?]): this.type = {
setConfig(config)
this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object ChenParse:
// Special string used to separate joern-parse opts from frontend-specific opts
val ArgsDelimitor = "--frontend-args"
val DefaultCpgOutFile = "cpg.bin"
var generator: CpgGenerator = _
var generator: CpgGenerator = scala.compiletime.uninitialized

def main(args: Array[String]): Unit =
run(args) match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StepsTest extends AnyWordSpec with Matchers {
"providing multiple" in {
// find two arbitrary methods so we can find it again in the next step
val methods = cpg.method.toList.take(2)
val results: List[Method] = cpg.method.id(methods.map(_.id): _*).toList
val results: List[Method] = cpg.method.id(methods.map(_.id)*).toList

results.size shouldBe 2
results.toSet shouldBe methods.toSet
Expand Down

0 comments on commit 1bc82ba

Please sign in to comment.