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 new rule to check sdk_no_wait() usage #292

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Juliehzl
Copy link
Contributor

@Juliehzl Juliehzl commented Apr 9, 2021

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.

@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.')
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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):
Copy link
Member

@evelyn-ys evelyn-ys Apr 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def support_no_wait(self, command_name):
def lack_of_sdk_no_wait(self, command_name):

@yonzhan yonzhan requested a review from kairu-ms April 9, 2021 09:14
pattern = re.compile("sdk_no_wait")
support_no_wait = pattern.search(source_code)
if no_wait:
return command_name
Copy link
Contributor

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

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.

3 participants