Some code paths are unreachable because the
continue statements unconditionally exit a block of code.
The code statements after the above keywords (which exit the code block) will not execute.
.bind()or local functions in JSX properties JS-0417
.bind() or passing local callback functions as props to react component incurs a performance overhead.
React.useCallback, or if possible, moving the callback definition outside the component.
EXCEPTIONS: This rule may not apply if your react component is only rendered once, or if your application is not performance sensitive. In such cases, consider adding a skipcq to prevent DeepSource from raising this issue on a single component. Alternatively, for small applications, you could add this issue in the ignore rules section.
Note that the performance overhead is not determined by the size of the callback function, but instead the number of times the component is rendered.
componentDidMount() is invoked immediately after a component is mounted. This method is a good place to load data from an endpoint as it is invoked before the browser updates the screen.
componentDidMount() will trigger an extra rendering, so it causes performance issues as
render() will be called twice.
String#match should only be used when we need to use the parts of a string that match a specific pattern:
arguments.calleeshould not be used JS-0053
The use of
Imports are an ES6/ES2015 standard for making the functionality of other modules available in your current module. In CommonJS this is implemented through the
require() call. Why would you want to restrict imports?
Symbol function may have an optional description:
Unused variables are generally considered a code smell and should be avoided.
catchclauses found JS-0112
catch clause that only rethrows the original error is redundant, and has no effect on the runtime behavior of the program. These redundant clauses can be a source of confusion and code bloat, so it's better to disallow these unnecessary catch clauses.
For the execution of the watchers, the $digest method will start from the scope in which we call the method. This will cause an performance improvement comparing to the $apply method, who start from the $rootScope. Rule based on Angular 1.x
Impure pipes should be avoided because they are invoked on each change-detection cycle. Impure pipes can’t leverage caching, instance re-use and simple tests.
Cyclomatic complexity is a quantitative measure of the number of linearly independent paths through a program’s source code. Cyclomatic complexity over some threshold indicates that the logic should be moved outside the template.
Meteor.setTimeout can be used to defer the execution of a function, but Meteor has a built-in method for deferring called
Meteor.defer. It is better to use the dedicated method instead of relying on a side-effect of
Meteor.defer is preferred because it uses native
postMessage methods if available. Otherwise, it can fall back to
setTimeout adds a delay of at least 2ms in Chrome, 10ms in other browsers, which results in performance issues.
Enforce img alt attribute does not contain the word image, picture, or photo. Screenreaders already announce img elements as an image. There is no need to use words such as image, photo, and/or picture.
Elements with an interactive role and interaction handlers (mouse or key press) must be focusable as it will be helpful for keyboard and screen reader users.
Enforce onmouseover/onmouseout are accompanied by onfocus/onblur. Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users.
Enforces that no distracting elements are used. Elements that can be visually distracting can cause accessibility issues with visually impaired users. Such elements are most likely deprecated, and should be avoided. By default, the following elements are visually distracting:
Non-interactive HTML elements and non-interactive ARIA roles indicate content and containers in the user interface. A non-interactive element does not support event handlers (mouse and key handlers). Non-interactive elements include
<ol>. Non-interactive WAI-ARIA roles include
tabIndexdeclared on a non-interactive element JS-0762
Tab key navigation should be limited to elements on the page that can be interacted with. Thus it is not necessary to add a tabindex to items in an unordered list, for example, to make them navigable through assistive technology. These applications already afford page traversal mechanisms based on the HTML of the page. Generally, we should try to reduce the size of the page's tab ring rather than increasing it.
Some HTML elements have native semantics that are implemented by the browser. This includes default/implicit ARIA roles. Setting an ARIA role that matches its default/implicit role is redundant since it is already set by the browser.