-
Notifications
You must be signed in to change notification settings - Fork 0
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
SarifFixAdapter #4
Conversation
### What's done: * Introduce primary logic and tests
### What's done: * Apply fix objects from SARIF to the test files
fixpatches/src/commonTest/kotlin/com/saveourtool/sarifutils/adapter/SarifFixAdapterTest.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonTest/kotlin/com/saveourtool/sarifutils/adapter/SarifFixAdapterTest.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonTest/kotlin/com/saveourtool/sarifutils/adapter/SarifFixAdapterTest.kt
Outdated
Show resolved
Hide resolved
### What's done: * Algorithm improvements and more tests
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/config/FileReplacements.kt
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/files/FileUtils.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/files/FileUtils.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/files/FileUtils.kt
Outdated
Show resolved
Hide resolved
### What's done: * Improve algorithm and expand tests
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
### What's done: * Polishing
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/files/FileUtils.kt
Outdated
Show resolved
Hide resolved
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/files/FileUtils.kt
Outdated
Show resolved
Hide resolved
### What's done: * Сonsider `uriBaseId` for file paths in Sarif * Add tests * Polishing
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/adapter/SarifFixAdapter.kt
Outdated
Show resolved
Hide resolved
### What's done: * Enhance logging
### What's done: * Support replacements of whole line
val currentArtifactLocation = artifactChange.artifactLocation | ||
if (currentArtifactLocation.uri == null) { | ||
println("Error: Field `uri` is absent in `artifactLocation`! Ignore this artifact change") | ||
null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to store null here? Just filter out objects that have empty uri
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's placed inside mapNotNull
in if-else
condition, so any branch should return something, here we need to log such cases, that's why I separate it. null
will be filtered by mapNotNull
fs.canonicalize(it) == fullPathOfFileFromSarif | ||
} | ||
if (testFile == null) { | ||
println("Couldn't find appropriate test file on the path ${fileReplacements.filePath}, which provided in Sarif!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test files? what is the relation of test files to a separate sarif library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, changed to targetFiles
* @param ruleReplacements list of replacements by all rules | ||
* @return filtered list of replacements by all rules | ||
*/ | ||
private fun filterRuleReplacements(ruleReplacements: RuleReplacements): RuleReplacements { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be changed completely with the algorithm stackoverflow proposed: check min and max in the interval.
If overlap - take first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, will be done under #13 in separate PR
* @param sarifFile path to the sarif file with fix object replacements | ||
* @param testFiles list of the test file, to which above fixes need to be applied | ||
*/ | ||
class SarifFixAdapter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it an adapter?
And also why do we need "testFiles"?
Forget word 'test'. It is targetFile
or something like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I name this by analogy from save-cli
, like we have SarifWarnAdapter
Can't imagine better name for now, so leave as is. Will change in future PR
test
-> target
changed
### What's done: * Rename testFiles to targetFiles
What's done: