lancetw/react-isomorphic-bundle

View on GitHub
src/client/admin/components/widget/MembersNavWidget.js

Summary

Maintainability
F
3 days
Test Coverage

Function render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    return (
      <div className="ui fluid vertical menu">
        <Link
          to="/ring/members"
Severity: Minor
Found in src/client/admin/components/widget/MembersNavWidget.js - About 1 hr to fix

    Function renderCounter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      renderCounter (index) {
        if (index === 0) {
          const count = isFinite(this.props.collect.count) ? this.props.collect.count : '-'
          return (
            <div className="ui orange label">{count}</div>
    Severity: Minor
    Found in src/client/admin/components/widget/MembersNavWidget.js - About 25 mins 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

    Expected 'this' to be used by class method 'renderLabel'.
    Open

      renderLabel (index) {

    Enforce that class methods utilize this (class-methods-use-this)

    If a class method does not use this, it can safely be made a static function.

    It's possible to have a class method which doesn't use this, such as:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        sayHi() {
            console.log("hi");
        }
    }
    
    let a = new A();
    a.sayHi(); // => "hi"

    In the example above, the sayHi method doesn't use this, so we can make it a static method:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        static sayHi() {
            console.log("hi");
        }
    }
    
    A.sayHi(); // => "hi"

    Also note in the above examples that the code calling the function on an instance of the class (let a = new A(); a.sayHi();) changes to calling it on the class itself (A.sayHi();).

    Rule Details

    This rule is aimed to flag class methods that do not use this.

    Examples of incorrect code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    
    class A {
        foo() {
            console.log("Hello World");     /*error Expected 'this' to be used by class method 'foo'.*/
        }
    }

    Examples of correct code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    class A {
        foo() {
            this.bar = "Hello World"; // OK, this is used
        }
    }
    
    class A {
        constructor() {
            // OK. constructor is exempt
        }
    }
    
    class A {
        static foo() {
            // OK. static methods aren't expected to use this.
        }
    }

    Options

    Exceptions

    "class-methods-use-this": [<enabled>, { "exceptMethods": [&lt;...exceptions&gt;] }]</enabled>

    The exceptMethods option allows you to pass an array of method names for which you would like to ignore warnings.

    Examples of incorrect code for this rule when used without exceptMethods:

    /*eslint class-methods-use-this: "error"*/
    
    class A {
        foo() {
        }
    }

    Examples of correct code for this rule when used with exceptMethods:

    /*eslint class-methods-use-this: ["error", { "exceptMethods": ["foo"] }] */
    
    class A {
        foo() {
        }
    }

    Source: http://eslint.org/docs/rules/

    Expected 'this' to be used by class method 'menuItemClass'.
    Open

      menuItemClass (selected, index) {

    Enforce that class methods utilize this (class-methods-use-this)

    If a class method does not use this, it can safely be made a static function.

    It's possible to have a class method which doesn't use this, such as:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        sayHi() {
            console.log("hi");
        }
    }
    
    let a = new A();
    a.sayHi(); // => "hi"

    In the example above, the sayHi method doesn't use this, so we can make it a static method:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        static sayHi() {
            console.log("hi");
        }
    }
    
    A.sayHi(); // => "hi"

    Also note in the above examples that the code calling the function on an instance of the class (let a = new A(); a.sayHi();) changes to calling it on the class itself (A.sayHi();).

    Rule Details

    This rule is aimed to flag class methods that do not use this.

    Examples of incorrect code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    
    class A {
        foo() {
            console.log("Hello World");     /*error Expected 'this' to be used by class method 'foo'.*/
        }
    }

    Examples of correct code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    class A {
        foo() {
            this.bar = "Hello World"; // OK, this is used
        }
    }
    
    class A {
        constructor() {
            // OK. constructor is exempt
        }
    }
    
    class A {
        static foo() {
            // OK. static methods aren't expected to use this.
        }
    }

    Options

    Exceptions

    "class-methods-use-this": [<enabled>, { "exceptMethods": [&lt;...exceptions&gt;] }]</enabled>

    The exceptMethods option allows you to pass an array of method names for which you would like to ignore warnings.

    Examples of incorrect code for this rule when used without exceptMethods:

    /*eslint class-methods-use-this: "error"*/
    
    class A {
        foo() {
        }
    }

    Examples of correct code for this rule when used with exceptMethods:

    /*eslint class-methods-use-this: ["error", { "exceptMethods": ["foo"] }] */
    
    class A {
        foo() {
        }
    }

    Source: http://eslint.org/docs/rules/

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      render () {
        return (
          <div className="ui fluid vertical menu">
            <Link
              to="/ring/members"
    Severity: Major
    Found in src/client/admin/components/widget/MembersNavWidget.js and 2 other locations - About 1 day to fix
    src/client/admin/components/widget/NavWidget.js on lines 112..144
    src/client/admin/components/widget/PermissionsNavWidget.js on lines 96..128

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 315.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

      renderCounter (index) {
        if (index === 0) {
          const count = isFinite(this.props.collect.count) ? this.props.collect.count : '-'
          return (
            <div className="ui orange label">{count}</div>
    Severity: Major
    Found in src/client/admin/components/widget/MembersNavWidget.js and 3 other locations - About 5 hrs to fix
    src/client/admin/components/widget/AdsNavWidget.js on lines 97..109
    src/client/admin/components/widget/NavWidget.js on lines 98..110
    src/client/admin/components/widget/PermissionsNavWidget.js on lines 82..94

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 148.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

      handleSearchKeyUp (event) {
        const keyword = event.target.value
        clearTimeout(this.timer)
        this.timer = setTimeout(() => {
          this.doSubmit(keyword)
    Severity: Major
    Found in src/client/admin/components/widget/MembersNavWidget.js and 3 other locations - About 2 hrs to fix
    src/client/admin/components/widget/AdsNavWidget.js on lines 56..63
    src/client/admin/components/widget/NavWidget.js on lines 57..64
    src/client/admin/components/widget/PermissionsNavWidget.js on lines 55..62

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 78.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      doSubmit (userInput) {
        this.props.fetchList({
          offset: 0,
          limit: 5,
          status: this.props.selected,
    Severity: Major
    Found in src/client/admin/components/widget/MembersNavWidget.js and 1 other location - About 2 hrs to fix
    src/client/admin/components/widget/AdsNavWidget.js on lines 37..46

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 75.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    JSX props should not use ::
    Open

                  onChange={::this.handleSearchChange}

    For more information visit Source: http://eslint.org/docs/rules/

    Using string literals in ref attributes is deprecated.
    Open

                  ref="search"

    For more information visit Source: http://eslint.org/docs/rules/

    The closing bracket must be aligned with the line containing the opening tag (expected column 9 on the next line)
    Open

              className={this.menuItemClass(this.props.selected, 1)}>

    For more information visit Source: http://eslint.org/docs/rules/

    The closing bracket must be aligned with the line containing the opening tag (expected column 13 on the next line)
    Open

                  placeholder="搜尋..." />

    For more information visit Source: http://eslint.org/docs/rules/

    JSX props should not use ::
    Open

                  onFocus={::this.handleSearchFocus}

    For more information visit Source: http://eslint.org/docs/rules/

    JSX not allowed in files with extension '.js'
    Open

            <div className="ui orange label">{count}</div>

    For more information visit Source: http://eslint.org/docs/rules/

    The closing bracket must be aligned with the line containing the opening tag (expected column 9 on the next line)
    Open

              className={this.menuItemClass(this.props.selected, 0)}>

    For more information visit Source: http://eslint.org/docs/rules/

    JSX props should not use ::
    Open

                  onKeyUp={::this.handleSearchKeyUp}

    For more information visit Source: http://eslint.org/docs/rules/

    JSX props should not use ::
    Open

                  onBlur={::this.handleBlur}

    For more information visit Source: http://eslint.org/docs/rules/

    Prop type object is forbidden
    Open

        collect: PropTypes.object.isRequired,

    For more information visit Source: http://eslint.org/docs/rules/

    JSX props should not use ::
    Open

                  onKeyDown={::this.handleSearchKeyDown}

    For more information visit Source: http://eslint.org/docs/rules/

    Empty components are self-closing
    Open

                <i className="search icon"></i>

    For more information visit Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status