ytanruengsri/eslint-plugin-react-ssr

View on GitHub

Showing 4 of 4 total issues

Function makeNoMethodSetStateRule has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

function makeNoMethodSetStateRule(methodName) {
  return {
    meta: {
      docs: {
        description: `Prevent usage of window/document in ${methodName}`,
Severity: Minor
Found in lib/util/makeNoMethodDomRule.js - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function makeNoMethodSetStateRule has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function makeNoMethodSetStateRule(methodName) {
  return {
    meta: {
      docs: {
        description: `Prevent usage of window/document in ${methodName}`,
Severity: Major
Found in lib/util/makeNoMethodDomRule.js - About 2 hrs to fix

    Function create has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        create: function(context) {
          const mode = context.options[0] || 'allow-in-func';
    
          // --------------------------------------------------------------------------
          // Public
    Severity: Minor
    Found in lib/util/makeNoMethodDomRule.js - About 1 hr to fix

      Function CallExpression has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              CallExpression: function(node) {
                const callee = node.callee;
      
                const useWindow =
                  (callee.name === 'window') ||
      Severity: Minor
      Found in lib/util/makeNoMethodDomRule.js - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language