-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bf9038
commit 8f253eb
Showing
10 changed files
with
175 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ polystat { | |
outputTo = . | ||
tempDir = tmp | ||
outputFormats = [sarif] | ||
# excludeRules = [e, c, dialect] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
## Polystat v0.1.3 | ||
## Polystat v0.1.4 | ||
|
||
In this release the `odin` dependency was updated to 0.4.0. | ||
In this release the `py2eo` project was integrated into `polystat-cli`. You can now run: | ||
``` | ||
polystat py --in python_files | ||
``` | ||
|
||
The CD pipeline was updated to allow releasing a specified version. | ||
...to analyze a directory with a bunch of python files. For more options and explanations, run: | ||
``` | ||
polystat --help | ||
``` | ||
or | ||
``` | ||
polystat list --config | ||
``` | ||
if you want to use the config file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def conditionalCheck2(): | ||
a = 4 | ||
b = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.polystat | ||
|
||
import cats.effect.IO | ||
import PolystatConfig.* | ||
import InputUtils.* | ||
import org.polystat.odin.analysis.ASTAnalyzer | ||
import org.polystat.odin.analysis.EOOdinAnalyzer | ||
import org.polystat.odin.parser.EoParser.sourceCodeEoParser | ||
import cats.syntax.traverse.* | ||
import cats.syntax.foldable.* | ||
|
||
object EO: | ||
|
||
def runAnalyzers( | ||
analyzers: List[ASTAnalyzer[IO]] | ||
)(code: String): IO[List[EOOdinAnalyzer.OdinAnalysisResult]] = | ||
analyzers.traverse(a => | ||
EOOdinAnalyzer | ||
.analyzeSourceCode(a)(code)(cats.Monad[IO], sourceCodeEoParser[IO]()) | ||
) | ||
|
||
def analyze(cfg: ProcessedConfig): IO[Unit] = | ||
val inputFiles = readCodeFromInput(".eo", cfg.input) | ||
inputFiles | ||
.evalMap { case (codePath, code) => | ||
for | ||
_ <- IO.println(s"Analyzing $codePath...") | ||
analyzed <- runAnalyzers(cfg.filteredAnalyzers)(code) | ||
_ <- cfg.output match | ||
case Output.ToConsole => IO.println(analyzed) | ||
case Output.ToDirectory(out) => | ||
cfg.fmts.traverse_ { case OutputFormat.Sarif => | ||
val outPath = | ||
out / "sarif" / codePath.replaceExt(".sarif.json") | ||
val sarifJson = SarifOutput(analyzed).json.toString | ||
IO.println(s"Writing results to $outPath") *> | ||
writeOutputTo(outPath)(sarifJson) | ||
} | ||
yield () | ||
} | ||
.compile | ||
.drain | ||
end analyze | ||
end EO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.polystat | ||
|
||
import org.polystat.py2eo.transpiler.Transpile | ||
import fs2.io.file.{Files, Path} | ||
import cats.effect.{IO, IOApp} | ||
import org.polystat.PolystatConfig.* | ||
import org.polystat.InputUtils.* | ||
|
||
object Python: | ||
|
||
def analyze(cfg: ProcessedConfig): IO[Unit] = | ||
for | ||
tmp <- cfg.tempDir | ||
_ <- readCodeFromInput(".py", cfg.input) | ||
.evalMap { case (path, code) => | ||
for | ||
maybeCode <- IO.blocking(Transpile(path.toString, code)) | ||
_ <- maybeCode match | ||
case Some(code) => | ||
writeOutputTo(tmp / path.replaceExt(".eo"))(code) | ||
case None => IO.println(s"Couldn't analyze $path...") | ||
yield () | ||
} | ||
.compile | ||
.drain | ||
_ <- EO.analyze(cfg.copy(input = Input.FromDirectory(tmp))) | ||
yield () | ||
|
||
end Python |