Skip to content
Merged
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
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.1.93
++++++
* `azdev linter`: Fix `None` path for added files in `git diff` for `missing_command_example` rule

0.1.92
++++++
* `azdev linter`: Add `missing_command_example` rule
Expand Down
2 changes: 1 addition & 1 deletion azdev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# license information.
# -----------------------------------------------------------------------------

__VERSION__ = '0.1.92'
__VERSION__ = '0.1.93'
11 changes: 8 additions & 3 deletions azdev/operations/linter/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,13 @@ def check_missing_command_example(self):
cmd_help = self._loaded_help.get(cmd, None)
if not cmd_help:
continue
# parameters = cmd_help.parameters
# add if future parameter set required
cmd_suffix = cmd.split()[-1]
cmd_example_threshold = get_cmd_example_threshold(cmd_suffix, cmd_example_config)
if cmd_example_threshold == 0:
continue
if not hasattr(cmd_help, "parameters") or len(cmd_help.parameters) == 0:
# skip cmd without parameters
continue
if not hasattr(cmd_help, "examples") or len(cmd_help.examples) < cmd_example_threshold:
violations.append(f'Command `{cmd}` should have at least {cmd_example_threshold} example(s)')
if violations:
Expand Down Expand Up @@ -427,7 +428,9 @@ def _detect_modified_command(self):
modified_commands = set()
diff_patches = diff_branch_file_patch(repo=self.git_repo, target=self.git_target, source=self.git_source)
for change in diff_patches:
file_path, filename = self._split_path(change.a_path)
if not change.b_path or not change.diff:
continue
file_path, filename = self._split_path(change.b_path)
if "commands.py" not in filename and "aaz" not in file_path:
continue
current_lines = self._read_blob_lines(change.b_blob)
Expand Down Expand Up @@ -462,6 +465,8 @@ def _get_diffed_patches(self):
return
diff_patches = diff_branch_file_patch(repo=self.git_repo, target=self.git_target, source=self.git_source)
for change in diff_patches:
if not change.diff:
continue
patch = change.diff.decode("utf-8")
added_lines = [line for line in patch.splitlines() if line.startswith('+') and not line.startswith('+++')]
self.diffed_lines |= set(added_lines)
Expand Down