lancetw/react-isomorphic-bundle

View on GitHub
src/client/admin/components/StatisticsComponent.js

Summary

Maintainability
C
7 hrs
Test Coverage

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

  render () {
    const { items, countPosts, countUsers, year, month } = this.props.collect

    return (
      <main className="ui column page grid container">
Severity: Major
Found in src/client/admin/components/StatisticsComponent.js - About 3 hrs to fix

    Missing space after =>.
    Open

          x: this.props.collect.data.map((d,_)=>moment(d.day).format()),

    Require space before/after arrow function's arrow (arrow-spacing)

    This rule normalize style of spacing before/after an arrow function's arrow(=>).

    /*eslint-env es6*/
    
    // { "before": true, "after": true }
    (a) => {}
    
    // { "before": false, "after": false }
    (a)=>{}

    Rule Details

    This rule takes an object argument with before and after properties, each with a Boolean value.

    The default configuration is { "before": true, "after": true }.

    true means there should be one or more spaces and false means no spaces.

    Examples of incorrect code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    ()=> {};
    () =>{};
    (a)=> {};
    (a) =>{};
    a =>a;
    a=> a;
    ()=> {'\n'};
    () =>{'\n'};

    Examples of correct code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    () => {};
    (a) => {};
    a => a;
    () => {'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=> {'\n'};

    Examples of correct code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    ()=>{};
    (a)=>{};
    ()=>{'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=>{'\n'};

    Examples of correct code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    ()=> {};
    (a)=> {};
    ()=> {'\n'};

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

    Useless constructor.
    Open

      constructor (props) {

    Disallow unnecessary constructor (no-useless-constructor)

    ES2015 provides a default class constructor if one is not specified. As such, it is unnecessary to provide an empty constructor or one that simply delegates into its parent class, as in the following examples:

    class A {
        constructor () {
        }
    }
    
    class A extends B {
        constructor (value) {
          super(value);
        }
    }

    Rule Details

    This rule flags class constructors that can be safely removed without changing how the class works.

    Examples

    Examples of incorrect code for this rule:

    /*eslint no-useless-constructor: "error"*/
    /*eslint-env es6*/
    
    class A {
        constructor () {
        }
    }
    
    class A extends B {
        constructor (...args) {
          super(...args);
        }
    }

    Examples of correct code for this rule:

    /*eslint no-useless-constructor: "error"*/
    
    class A { }
    
    class A {
        constructor () {
            doSomething();
        }
    }
    
    class A extends B {
        constructor() {
            super('foo');
        }
    }
    
    class A extends B {
        constructor() {
            super();
            doSomething();
        }
    }

    When Not To Use It

    If you don't want to be notified about unnecessary constructors, you can safely disable this rule. Source: http://eslint.org/docs/rules/

    Missing space after =>.
    Open

          y: this.props.collect.data.map((d,_)=>d.count),

    Require space before/after arrow function's arrow (arrow-spacing)

    This rule normalize style of spacing before/after an arrow function's arrow(=>).

    /*eslint-env es6*/
    
    // { "before": true, "after": true }
    (a) => {}
    
    // { "before": false, "after": false }
    (a)=>{}

    Rule Details

    This rule takes an object argument with before and after properties, each with a Boolean value.

    The default configuration is { "before": true, "after": true }.

    true means there should be one or more spaces and false means no spaces.

    Examples of incorrect code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    ()=> {};
    () =>{};
    (a)=> {};
    (a) =>{};
    a =>a;
    a=> a;
    ()=> {'\n'};
    () =>{'\n'};

    Examples of correct code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    () => {};
    (a) => {};
    a => a;
    () => {'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=> {'\n'};

    Examples of correct code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    ()=>{};
    (a)=>{};
    ()=>{'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=>{'\n'};

    Examples of correct code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    ()=> {};
    (a)=> {};
    ()=> {'\n'};

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

    Unexpected block statement surrounding arrow body.
    Open

                      {!isEmpty(items) && items.map((item, i) => {

    Require braces in arrow function body (arrow-body-style)

    Arrow functions have two syntactic forms for their function bodies. They may be defined with a block body (denoted by curly braces) () => { ... } or with a single expression () => ..., whose value is implicitly returned.

    Rule Details

    This rule can enforce or disallow the use of braces around arrow function body.

    Options

    The rule takes one or two options. The first is a string, which can be:

    • "always" enforces braces around the function body
    • "as-needed" enforces no braces where they can be omitted (default)
    • "never" enforces no braces around the function body (constrains arrow functions to the role of returning an expression)

    The second one is an object for more fine-grained configuration when the first option is "as-needed". Currently, the only available option is requireReturnForObjectLiteral, a boolean property. It's false by default. If set to true, it requires braces and an explicit return for object literals.

    "arrow-body-style": ["error", "always"]

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint arrow-body-style: ["error", "always"]*/
    /*eslint-env es6*/
    let foo = () => 0;

    Examples of correct code for this rule with the "always" option:

    let foo = () => {
        return 0;
    };
    let foo = (retv, name) => {
        retv[name] = true;
        return retv;
    };

    as-needed

    Examples of incorrect code for this rule with the default "as-needed" option:

    /*eslint arrow-body-style: ["error", "as-needed"]*/
    /*eslint-env es6*/
    
    let foo = () => {
        return 0;
    };
    let foo = () => {
        return {
           bar: {
                foo: 1,
                bar: 2,
            }
        };
    };

    Examples of correct code for this rule with the default "as-needed" option:

    /*eslint arrow-body-style: ["error", "as-needed"]*/
    /*eslint-env es6*/
    
    let foo = () => 0;
    let foo = (retv, name) => {
        retv[name] = true;
        return retv;
    };
    let foo = () => ({
        bar: {
            foo: 1,
            bar: 2,
        }
    });
    let foo = () => { bar(); };
    let foo = () => {};
    let foo = () => { /* do nothing */ };
    let foo = () => {
        // do nothing.
    };
    let foo = () => ({ bar: 0 });

    requireReturnForObjectLiteral

    This option is only applicable when used in conjunction with the "as-needed" option.

    Examples of incorrect code for this rule with the { "requireReturnForObjectLiteral": true } option:

    /*eslint arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
    /*eslint-env es6*/
    let foo = () => ({});
    let foo = () => ({ bar: 0 });

    Examples of correct code for this rule with the { "requireReturnForObjectLiteral": true } option:

    /*eslint arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
    /*eslint-env es6*/
    
    let foo = () => {};
    let foo = () => { return { bar: 0 }; };

    never

    Examples of incorrect code for this rule with the "never" option:

    /*eslint arrow-body-style: ["error", "never"]*/
    /*eslint-env es6*/
    
    let foo = () => {
        return 0;
    };
    let foo = (retv, name) => {
        retv[name] = true;
        return retv;
    };

    Examples of correct code for this rule with the "never" option:

    /*eslint arrow-body-style: ["error", "never"]*/
    /*eslint-env es6*/
    
    let foo = () => 0;
    let foo = () => ({ foo: 0 });

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

    Missing space before =>.
    Open

          x: this.props.collect.data.map((d,_)=>moment(d.day).format()),

    Require space before/after arrow function's arrow (arrow-spacing)

    This rule normalize style of spacing before/after an arrow function's arrow(=>).

    /*eslint-env es6*/
    
    // { "before": true, "after": true }
    (a) => {}
    
    // { "before": false, "after": false }
    (a)=>{}

    Rule Details

    This rule takes an object argument with before and after properties, each with a Boolean value.

    The default configuration is { "before": true, "after": true }.

    true means there should be one or more spaces and false means no spaces.

    Examples of incorrect code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    ()=> {};
    () =>{};
    (a)=> {};
    (a) =>{};
    a =>a;
    a=> a;
    ()=> {'\n'};
    () =>{'\n'};

    Examples of correct code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    () => {};
    (a) => {};
    a => a;
    () => {'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=> {'\n'};

    Examples of correct code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    ()=>{};
    (a)=>{};
    ()=>{'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=>{'\n'};

    Examples of correct code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    ()=> {};
    (a)=> {};
    ()=> {'\n'};

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

    Missing space before =>.
    Open

          y: this.props.collect.data.map((d,_)=>d.count),

    Require space before/after arrow function's arrow (arrow-spacing)

    This rule normalize style of spacing before/after an arrow function's arrow(=>).

    /*eslint-env es6*/
    
    // { "before": true, "after": true }
    (a) => {}
    
    // { "before": false, "after": false }
    (a)=>{}

    Rule Details

    This rule takes an object argument with before and after properties, each with a Boolean value.

    The default configuration is { "before": true, "after": true }.

    true means there should be one or more spaces and false means no spaces.

    Examples of incorrect code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    ()=> {};
    () =>{};
    (a)=> {};
    (a) =>{};
    a =>a;
    a=> a;
    ()=> {'\n'};
    () =>{'\n'};

    Examples of correct code for this rule with the default { "before": true, "after": true } option:

    /*eslint arrow-spacing: "error"*/
    /*eslint-env es6*/
    
    () => {};
    (a) => {};
    a => a;
    () => {'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=> {'\n'};

    Examples of correct code for this rule with the { "before": false, "after": false } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": false }]*/
    /*eslint-env es6*/
    
    ()=>{};
    (a)=>{};
    ()=>{'\n'};

    Examples of incorrect code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    () =>{};
    (a) => {};
    ()=>{'\n'};

    Examples of correct code for this rule with the { "before": false, "after": true } option:

    /*eslint arrow-spacing: ["error", { "before": false, "after": true }]*/
    /*eslint-env es6*/
    
    ()=> {};
    (a)=> {};
    ()=> {'\n'};

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

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

                        <div className="field">
                          <input ref="year" type="number" max="2038" min="1970" placeholder="年" defaultValue={year} />
                        </div>
    Severity: Major
    Found in src/client/admin/components/StatisticsComponent.js and 1 other location - About 1 hr to fix
    src/client/admin/components/StatisticsComponent.js on lines 68..70

    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 57.

    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

                        <div className="field">
                          <input ref="month" type="number" max="12" min="1" placeholder="月" defaultValue={month} />
                        </div>
    Severity: Major
    Found in src/client/admin/components/StatisticsComponent.js and 1 other location - About 1 hr to fix
    src/client/admin/components/StatisticsComponent.js on lines 65..67

    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 57.

    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

                      <div className="ui horizontal statistic">
                        <div className="value">
                          {countPosts}
                        </div>
                        <div className="label">
    Severity: Major
    Found in src/client/admin/components/StatisticsComponent.js and 1 other location - About 1 hr to fix
    src/client/admin/components/StatisticsComponent.js on lines 85..92

    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 57.

    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

                      <div className="ui horizontal statistic">
                        <div className="value">
                          {countUsers}
                        </div>
                        <div className="label">
    Severity: Major
    Found in src/client/admin/components/StatisticsComponent.js and 1 other location - About 1 hr to fix
    src/client/admin/components/StatisticsComponent.js on lines 77..84

    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 57.

    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 3 locations. Consider refactoring.
    Open

                        <button className="ui icon button" onClick={this.handleSubmit}>
                          <i className="search icon"></i>
                        </button>
    Severity: Minor
    Found in src/client/admin/components/StatisticsComponent.js and 2 other locations - About 30 mins to fix
    src/shared/components/ManageComponent.js on lines 197..199
    src/shared/components/PostComponent.js on lines 678..682

    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 45.

    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

    Empty components are self-closing
    Open

                <div className="image logo admin"></div>

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

    Expected indentation of 26 space characters but found 24.
    Open

                            </div>

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

    Expected indentation of 20 space characters but found 18.
    Open

                      {!isEmpty(items) && items.map((item, i) => {

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

    Using this.refs is deprecated.
    Open

        const year = +ReactDOM.findDOMNode(this.refs.year).value

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

    Expected indentation of 20 space characters but found 18.
    Open

                      </tr></thead>

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

    Empty components are self-closing
    Open

                    <div className="ui hidden divider"></div>

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

    Expected indentation of 24 space characters but found 22.
    Open

                          </h4></td>

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

    Using string literals in ref attributes is deprecated.
    Open

                          <input ref="month" type="number" max="12" min="1" placeholder="月" defaultValue={month} />

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

    Empty components are self-closing
    Open

                    <div id="plot"></div>

    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 not allowed in files with extension '.js'
    Open

          <main className="ui column page grid container">

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

    Do not use findDOMNode
    Open

        const year = +ReactDOM.findDOMNode(this.refs.year).value

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

    Using this.refs is deprecated.
    Open

        const month = +ReactDOM.findDOMNode(this.refs.month).value

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

    Expected indentation of 22 space characters but found 20.
    Open

                        <th>發文數量</th>

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

    Expected indentation of 28 space characters but found 26.
    Open

                              </div>

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

    Using string literals in ref attributes is deprecated.
    Open

                          <input ref="year" type="number" max="2038" min="1970" placeholder="年" defaultValue={year} />

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

    Do not use findDOMNode
    Open

        const month = +ReactDOM.findDOMNode(this.refs.month).value

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

    Expected indentation of 22 space characters but found 20.
    Open

                        <tr>

    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