-
Notifications
You must be signed in to change notification settings - Fork 45
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
SONARHTML-198 Create rule S6852: Elements with an interactive role should support focus #284
Conversation
75da7cb
to
7968028
Compare
…ould support focus
7968028
to
49e25e3
Compare
private static boolean isHTMLTag(TagNode element) { | ||
return KNOWN_HTML_TAGS.stream().anyMatch(tag -> tag.equalsIgnoreCase(element.getNodeName())); | ||
} | ||
|
||
private static boolean hasInteractiveProps(TagNode element) { | ||
return INTERACTIVE_PROPS.stream().anyMatch(prop -> { | ||
var attr = element.getAttribute(prop); | ||
return attr != null && !attr.isEmpty(); | ||
}); | ||
} | ||
|
||
private static boolean hasInteractiveRole(TagNode element) { | ||
return INTERACTIVE_ROLES.stream().anyMatch(role -> role.equalsIgnoreCase(element.getAttribute("role"))); | ||
} | ||
|
||
private static boolean isInteractiveElement(TagNode element) { | ||
return INTERACTIVE_ELEMENTS.stream().anyMatch(tag -> tag.equalsIgnoreCase(element.getNodeName())); | ||
} | ||
|
||
private static boolean isNoninteractiveElement(TagNode element) { | ||
return NON_INTERACTIVE_ELEMENTS.stream().anyMatch(tag -> tag.equalsIgnoreCase(element.getNodeName())); | ||
} | ||
|
||
private static boolean hasPresentationRole(TagNode element) { | ||
return PRESENTATION_ROLES.stream().anyMatch(role -> role.equalsIgnoreCase(element.getAttribute("role"))); | ||
} | ||
|
||
private static boolean hasNoninteractiveRole(TagNode element) { | ||
return NON_INTERACTIVE_ROLES.stream().anyMatch(role -> role.equalsIgnoreCase(element.getAttribute("role"))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you refactor this to use the methods from HtmlConstants.java
, and move the new ones there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small refactoring suggestion, otherwise LGTM
Quality Gate passedIssues Measures |
No description provided.