-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add the option to ignore by block name, instead of by module #47
base: master
Are you sure you want to change the base?
Conversation
xenon/__init__.py
Outdated
@@ -36,6 +36,9 @@ def parse_args(): | |||
help='Comma separated list of patterns to ignore. If ' | |||
'they are directories, Xenon won\'t even descend into ' | |||
'them') | |||
parser.add_argument('-ib', '--ignore-blocks', metavar='<str>', dest='ignore_blocks', |
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'd like to keep the convention that short options have a single letter only. Let's pick a letter that is currently unused.
Thank you for your contribution! I find this addition quite useful. Two things are necessary before I can merge it:
|
|
||
for block_to_ignore in args.ignore_blocks.split(','): | ||
module_name, block_name = block_to_ignore.split(':') | ||
blocks_to_ignore[module_name.strip()].append(block_name.strip()) |
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.
Let's use defaultdict(set)
and .add
, since this is used to check for existence. For big codebases it'll make a difference as membership checks with set are an O(1) operation as opposed to O(n) with lists.
@@ -34,6 +36,24 @@ def analyze(args, logger): | |||
return find_infractions(args, logger, results), results | |||
|
|||
|
|||
def build_blocks_to_ignore(args): |
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.
This functionality should have at least one unit test.
I want to use xenon to prevent developers in my organization from adding new bad blocks, but still don't fail for existing bad blocks. Ignore/Exclude only allows to exclude by module, this isn't specific enough for us.