Skip to content

Commit

Permalink
file size filtering change
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-privado committed Mar 26, 2024
1 parent 79866b2 commit 4173e78
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/scala/ai/privado/passes/PropertyParserPass.scala
Original file line number Diff line number Diff line change
Expand Up @@ -423,21 +423,20 @@ class PropertyParserPass(
)
.filter(file => !file.contains("delombok"))
.filter(file => Utilities.isFileProcessable(file, ruleCache) && (!file.matches(".*node_modules.*")))
.filter(file => filterUsingFileSize(file, ruleCache))
.distinct

filterFilesWithDir(filterUsingFileSize(propertyFiles, ruleCache), ruleCache)
filterFilesWithDir(propertyFiles, ruleCache)
}

private def filterUsingFileSize(filePaths: List[String], ruleCache: RuleCache): List[String] = {
private def filterUsingFileSize(filePath: String, ruleCache: RuleCache): Boolean = {
val fileLimit = ruleCache.getSystemConfigByKey(Constants.PropertyFileSizeLimit, true)
if (fileLimit.nonEmpty) {
filePaths.filter(filePath => {
val file = new File(filePath)
val fileSizeInKiloByte = file.length() / 1024 // Get the size in KB
fileSizeInKiloByte <= fileLimit.toInt
})
val file = new File(filePath)
val fileSizeInKiloByte = file.length() / 1024 // Get the size in KB
fileSizeInKiloByte <= fileLimit.toInt
} else {
filePaths
true
}
}

Expand Down

0 comments on commit 4173e78

Please sign in to comment.