-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rm110 * changelog * added to config * remove UT * added the UT * added docstring
- Loading branch information
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Moved RM110 validation to the new format. Ensuring all commands are documented in the README. | ||
type: feature | ||
pr_number: 4542 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
demisto_sdk/commands/validate/validators/RM_validators/RM110_is_commands_in_readme.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List | ||
|
||
from demisto_sdk.commands.common.constants import GitStatuses | ||
from demisto_sdk.commands.content_graph.objects.integration import Integration | ||
from demisto_sdk.commands.content_graph.parsers.related_files import RelatedFileType | ||
from demisto_sdk.commands.validate.validators.base_validator import ( | ||
BaseValidator, | ||
ValidationResult, | ||
) | ||
|
||
ContentTypes = Integration | ||
COMMANDS_EXCLUDED_FROM_README_DOCUMENTATION = [ | ||
"get-mapping-fields", | ||
"xsoar-search-incidents", | ||
"xsoar-get-incident", | ||
"get-remote-data", | ||
"update-remote-data", | ||
"get-modified-remote-data", | ||
"update-remote-system", | ||
] | ||
|
||
|
||
class IsCommandsInReadmeValidator(BaseValidator[ContentTypes]): | ||
error_code = "RM110" | ||
description = "Validates that all commands are mentioned in the README file" | ||
rationale = "Ensuring all commands are documented in the README helps users understand the available functionality" | ||
error_message = ( | ||
"The following commands appear in the YML file but not in the README file: {}." | ||
) | ||
related_field = "commands" | ||
is_auto_fixable = False | ||
related_file_type = [RelatedFileType.README] | ||
expected_git_statuses = [GitStatuses.ADDED, GitStatuses.MODIFIED] | ||
|
||
def obtain_invalid_content_items( | ||
self, content_items: Iterable[ContentTypes] | ||
) -> List[ValidationResult]: | ||
results = [] | ||
for content_item in content_items: | ||
undocumented_commands = [ | ||
command.name | ||
for command in content_item.commands | ||
if command.name not in content_item.readme.file_content | ||
and command.name not in COMMANDS_EXCLUDED_FROM_README_DOCUMENTATION | ||
and not command.deprecated | ||
and not command.name.endswith("get-indicators") | ||
] | ||
if undocumented_commands: | ||
results.append( | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message.format( | ||
", ".join(undocumented_commands) | ||
), | ||
content_object=content_item, | ||
) | ||
) | ||
return results |