-
Notifications
You must be signed in to change notification settings - Fork 2
chore: change main()'s retval behavior #71
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
Open
airween
wants to merge
2
commits into
coreruleset:main
Choose a base branch
from
airween:chore/retvalfix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
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.
How come we know that
26367means error X or Y? 🤣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.
Your question is absolutely valid.
First of all: during the review I found a bug. There was a duplicated check which used one more bit than it was necessary, so now the expected value is not
26367but9983.9983in binary format is10 0110 1111 1111. The highest value is 2^(14-1).Here you can see the listed error containers. As you can see there are 13 containers. If any container contains an error then its bit will turn on to 1: the first container (
error_case_mistmatch) is2^0 := 1, the second (error_action_order) is2^1 := 2and so on. The last (13th) one is theerror_rule_hasnotest, its value can be2^(13-1) := 4096.There is one more possible error: the intendation error. This is a pre-check, it runs before the linter, so this "container" is not part of the linter class, and I didn't want to mix that. The most simple solution was to append at the end - this is why it uses
len(c.error_vars).Here is the full table:
ctl:auditlogpartsin wrong placeTXvariablePLtagPLscoreidtagtag:CRS...veraction or wrong valuetx:NwithoutcaptureThe last item is implicit an one, all others are explicit. This means if we extend the type of containers, the indentation error will have a new value.
The value
9983= case mismatch error | action order error |ctl:auditlogpartsin wrong place | undefinedTXvariable | inconsistentPLtag| inconsistentPLscore | duplicateid| unknowntag| notag:CRS...| noveraction or wrong value | indentation error.Error flag "combined transformation and ignorecase", "rule uses
tx:Nwithoutcapture" and "rule has no test" flags aren't set. None the any rule has tests, but I filled the missingid's in linter's test so the last one is not set because of this.I know this is impenetrable and hard to see but it's absolutely coherent and de-composable. I think this isn't necessary to understand, I just add this modification because here I offered a solution which was accepted by @theseion.
I can add some more code to make a map where we can check assertion's value not by an explicit integer, but a bit mask which compounded by flags, eg.
Would that be better?
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 get the bitwise form of returning errors, just trying to understand this need. Because we didn't returned all the errors before, so now we need to interpret the results in a different way.
It is better to have a map at least to have it easy to read.