Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses issue #241 .
It aims to enhance the readability of codeSnip script in output YAML. After going through the codebase, I found that as we are treating the
CodeSnip
as a string. Even while marshaling the rulesets using thegopkg.in/yaml.v2
package, theCodeSnip
remained a string literal, regardless of multiline or single-line string.To improve this, I wrote the outputViolations file with the new yaml content that has the
CodeSnip
as an object that encapsulates the code script, by storing the whole block of codeSnip object along with codeSnip object declaration in a new variable asx := "codeSnip: |\n" + incidents[j].CodeSnip
codesnip = append(codesnip, x)
The new yaml file was constructed by iteratively inserting codeSnip lines after each message object. But, here as you might have noticed that it will only work if for each message object there is a codeSnip object as well.
I have tried this in a sample code with the same yaml file demo-output.yaml, in that, after each message object it did insert the codeSnip as expected. We just need to add some \t escape sequences before the block of codeSnip.
Although this approach may seem unconventional, it was born out of exhaustive attempts to maintain the desired code output format. Despite various trials, the existing limitations of marshaling to YAML with the
CodeSnip
as a string persisted.While the code may need minor adjustments, I'm ready to make those changes. However, I kindly ask for your approval before proceeding with this approach of creating a temporary file and replacing it with our outputViolations file.