Skip to content

Commit

Permalink
🔖 Release v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi committed Mar 16, 2022
1 parent 167b73e commit 2411838
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.1.2] - 2022-03-16

### Added

- Two new metrics that are tracked: `PROGRAM_CLASSES` and `PROGRAM_METHODS`.

## [1.1.1] - 2022-03-16

### Added
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name := "Plume"
inThisBuild(
List(
organization := "com.github.plume-oss",
version := "1.1.1",
version := "1.1.2",
scalaVersion := "2.13.7",
crossScalaVersions := Seq("2.13.7", "3.1.1"),
resolvers ++= Seq(
Expand Down
24 changes: 13 additions & 11 deletions src/main/scala/com/github/plume/oss/Jimple2Cpg.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import soot.{G, PhaseOptions, Scene, SootClass}

import java.io.{File => JFile}
import java.nio.file.Paths
import scala.jdk.CollectionConverters.CollectionHasAsScala
import scala.jdk.CollectionConverters.{CollectionHasAsScala, IteratorHasAsScala}

object Jimple2Cpg {
val language: String = "PLUME"
Expand Down Expand Up @@ -122,14 +122,18 @@ class Jimple2Cpg {
logger.debug(s"Source files are: $sourceFileNames")

// Load classes into Soot
loadClassesIntoSoot(sourceFileNames)
val allSootClasses = loadClassesIntoSoot(sourceFileNames)
if (sootOnlyBuild) return cpg
val codeToProcess = new PlumeDiffPass(sourceFileNames, driver).createAndApply()

// Record statistics for experimental purposes
PlumeStatistics.setMetric(PlumeStatistics.PROGRAM_CLASSES, allSootClasses.size)
PlumeStatistics.setMetric(
PlumeStatistics.PROGRAM_METHODS,
allSootClasses.map(_.getMethodCount).sum
)
if (codeToProcess.isEmpty) {
logger.info("No files have changed since last update. Exiting...")
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_CLASSES, 0L)
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_METHODS, 0L)
return cpg
} else {
val numChangedMethods = codeToProcess
Expand All @@ -142,10 +146,7 @@ class Jimple2Cpg {
s"($numChangedMethods new or changed methods)"
)
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_CLASSES, codeToProcess.size)
PlumeStatistics.setMetric(
PlumeStatistics.CHANGED_METHODS,
numChangedMethods
)
PlumeStatistics.setMetric(PlumeStatistics.CHANGED_METHODS, numChangedMethods)
}

// After the diff pass any changed types are removed. Remaining types should be black listed to avoid duplicates
Expand Down Expand Up @@ -207,14 +208,15 @@ class Jimple2Cpg {
).distinct
}

private def loadClassesIntoSoot(sourceFileNames: List[String]): Unit = {
sourceFileNames
private def loadClassesIntoSoot(sourceFileNames: List[String]): Seq[SootClass] = {
val sootClasses = sourceFileNames
.map(getQualifiedClassPath)
.foreach { cp =>
.map { cp =>
Scene.v().addBasicClass(cp)
Scene.v().loadClassAndSupport(cp)
}
Scene.v().loadNecessaryClasses()
sootClasses
}

private def basePasses(
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/github/plume/oss/PlumeStatistics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object PlumeStatistics extends Enumeration {
type PlumeStatistic = Value

val TIME_OPEN_DRIVER, TIME_CLOSE_DRIVER, TIME_EXTRACTION, TIME_REACHABLE_BY_QUERYING,
CHANGED_CLASSES, CHANGED_METHODS = Value
CHANGED_CLASSES, CHANGED_METHODS, PROGRAM_CLASSES, PROGRAM_METHODS = Value

private val statistics: mutable.Map[PlumeStatistic, Long] =
PlumeStatistics.values.map((_, 0L)).to(collection.mutable.Map)
Expand Down

0 comments on commit 2411838

Please sign in to comment.