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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azdev/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class AzDevCli(CLI):

def get_cli_version(self):
from . import __VERSION__
from azdev import __VERSION__
return __VERSION__


Expand Down
12 changes: 12 additions & 0 deletions azdev/operations/linter/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

no_wait = self._command_loader.command_table[command_name].support_no_wait
op = self.get_op_handler()
import inspect
import re
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:

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

return False


# pylint: disable=too-many-instance-attributes
class LinterManager(object):
Expand Down
6 changes: 6 additions & 0 deletions azdev/operations/linter/rules/command_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ def group_delete_commands_should_confirm(linter, command_name):
if 'yes' not in linter.get_command_parameters(command_name):
raise RuleError("If this command deletes a collection, or group of resources. "
"Please make sure to ask for confirmation.")


@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.