Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuybarTapingo
Copy link

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.

@@ -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',
Copy link
Owner

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.

@rubik
Copy link
Owner

rubik commented May 1, 2022

Thank you for your contribution! I find this addition quite useful.

Two things are necessary before I can merge it:

  1. see my comment about the short option, I'd like to keep the convention that short options have only one letter for simplicity
  2. we should add a couple of sentences to the documentation about this new option: https://github.com/rubik/xenon/blob/master/docs/index.rst

@GuybarTapingo GuybarTapingo requested a review from rubik May 25, 2022 07:49

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())
Copy link
Owner

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):
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants