-
Notifications
You must be signed in to change notification settings - Fork 113
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 new rule to check sdk_no_wait() usage #292
base: dev
Are you sure you want to change the base?
Conversation
@CommandRule(LinterSeverity.HIGH) | ||
def no_wait_command(linter, command_name): | ||
if linter.support_no_wait(command_name): | ||
raise RuleError('Deprecated command is expired and should be removed.') |
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.
The error msg seems to report wrong error.
source_code = inspect.getsource(op) | ||
pattern = re.compile("sdk_no_wait") | ||
support_no_wait = pattern.search(source_code) | ||
if no_wait: |
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.
if no_wait: | |
if no_wait and not support_no_wait: |
@@ -169,6 +169,18 @@ def _get_loaded_help_description(self, entry): | |||
return help_entry.short_summary or help_entry.long_summary | |||
return help_entry | |||
|
|||
def support_no_wait(self, command_name): |
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.
def support_no_wait(self, command_name): | |
def lack_of_sdk_no_wait(self, command_name): |
pattern = re.compile("sdk_no_wait") | ||
support_no_wait = pattern.search(source_code) | ||
if no_wait: | ||
return command_name |
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.
Why return command_name
instead of True
Sometimes service team add support no wait for long running operation, but they forget to use sdk_no_wait() in custom function. Here is a new linter rule to check sdk_no_wait() usage.