Add the column offset to the issue model#618
Merged
Merged
Conversation
ericwb
requested changes
Dec 6, 2020
Member
ericwb
left a comment
There was a problem hiding this comment.
Is test_custom.py part of the column offset? If not, I suggest moving to a separate PR..
Contributor
Author
Yes, it's the test for the change. |
Contributor
Author
|
@ericwb changes updated as requested |
ericwb
approved these changes
Dec 17, 2020
Member
ericwb
left a comment
There was a problem hiding this comment.
I'd like to see the column indicator expanded to other formatters. But for now, this works for custom.
ericwb
added a commit
that referenced
this pull request
Dec 19, 2020
Recently, #618 introduced column offsets to the custom formatter. But other formatters should also show the column offset. Signed-off-by: Eric Brown <browne@vmware.com>
mikespallino
pushed a commit
to mikespallino/bandit
that referenced
this pull request
Aug 25, 2021
* Add the column offset to the issue model and expose via the custom formatter * Fix import order and update auto-help * Fetch property from dict but default to 0 for backward compatibility. Update the test as well * Update test_custom.py Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
mikespallino
pushed a commit
to mikespallino/bandit
that referenced
this pull request
Aug 25, 2021
Recently, PyCQA#618 introduced column offsets to the custom formatter. But other formatters should also show the column offset. Signed-off-by: Eric Brown <browne@vmware.com>
mikespallino
pushed a commit
to mikespallino/bandit
that referenced
this pull request
Jan 7, 2022
* Add the column offset to the issue model and expose via the custom formatter * Fix import order and update auto-help * Fetch property from dict but default to 0 for backward compatibility. Update the test as well * Update test_custom.py Co-authored-by: Eric Brown <ericwb@users.noreply.github.com>
mikespallino
pushed a commit
to mikespallino/bandit
that referenced
this pull request
Jan 7, 2022
Recently, PyCQA#618 introduced column offsets to the custom formatter. But other formatters should also show the column offset. Signed-off-by: Eric Brown <browne@vmware.com>
This was referenced Jan 25, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 proposed change propagates the
col_offsetof the offending node in the AST to theIssuedata model.Just as you can report line number this allows reporting of the column offset as well.
Column offset reporting is a standard feature on many linters, also I've noticed the way that bandit is used by linter integrations like VSCode could benefit having the col offset of the reported function call, import etc.
In some cases there are two issues on a single line and this would indicate which is belongs to which report.
I noticed the custom formatter didn't have any unit tests, so I added one for this change.
Example output below: