-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* validation RM106 * pre commit * remove DS107 * adding to changelog * fix space * fixes * remove pytest.mark.parametrize * adding new line at end of file * fixing build * Apply suggestions from code review Co-authored-by: Yuval Hayun <70104171+YuvHayun@users.noreply.github.com> * cr fixes * cr fixes * cr fixes * chageing it to git add and modiefied * removing from path based validation to yuval request * Update 4295.yml --------- Co-authored-by: Yuval Hayun <70104171+YuvHayun@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
105 additions
and
1 deletion.
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: ֹ"Converted the RM106 validation to the new format. The validation verifies that README doesn't contain the word 'demisto'". | ||
type: feature | ||
pr_number: 4295 |
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
49 changes: 49 additions & 0 deletions
49
demisto_sdk/commands/validate/validators/RM_validators/RM106_is_contain_demisto_word.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,49 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List, Union | ||
|
||
from demisto_sdk.commands.common.constants import GitStatuses | ||
from demisto_sdk.commands.common.tools import check_text_content_contain_sub_text | ||
from demisto_sdk.commands.content_graph.objects.integration import Integration | ||
from demisto_sdk.commands.content_graph.objects.pack import Pack | ||
from demisto_sdk.commands.content_graph.objects.playbook import Playbook | ||
from demisto_sdk.commands.content_graph.objects.script import Script | ||
from demisto_sdk.commands.content_graph.parsers.related_files import RelatedFileType | ||
from demisto_sdk.commands.validate.validators.base_validator import ( | ||
BaseValidator, | ||
ValidationResult, | ||
) | ||
|
||
ContentTypes = Union[Pack, Integration, Script, Playbook] | ||
|
||
|
||
class IsContainDemistoWordValidator(BaseValidator[ContentTypes]): | ||
error_code = "RM106" | ||
description = ( | ||
"Validate that none of the readme lines contains the the word 'demisto'." | ||
) | ||
rationale = ( | ||
"Ensure that the current name of the product is used rather than the old one." | ||
) | ||
error_message = "Invalid keyword 'demisto' was found in lines: {0}. For more information about the README See https://xsoar.pan.dev/docs/documentation/readme_file." | ||
related_field = "readme" | ||
is_auto_fixable = False | ||
related_file_type = [RelatedFileType.README] | ||
expected_git_statuses = [GitStatuses.ADDED, GitStatuses.MODIFIED] | ||
|
||
def is_valid(self, content_items: Iterable[ContentTypes]) -> List[ValidationResult]: | ||
return [ | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message.format(", ".join(lines_contain_demsito)), | ||
content_object=content_item, | ||
) | ||
for content_item in content_items | ||
if ( | ||
lines_contain_demsito := check_text_content_contain_sub_text( | ||
sub_text_list=["demisto"], | ||
is_lower=True, | ||
text=content_item.readme.file_content, | ||
) | ||
) | ||
] |