lancetw/react-isomorphic-bundle

View on GitHub
src/shared/components/wall/PostCard.js

Summary

Maintainability
B
5 hrs
Test Coverage

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

  render () {
    const card = this.props.data

    const eventDate = (card.startDate === card.endDate)
    ? toShortDate(card.endDate)
Severity: Major
Found in src/shared/components/wall/PostCard.js - About 2 hrs to fix

    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/

    Unexpected string concatenation.
    Open

        : toShortDate(card.startDate) + ' - ' + toShortDate(card.endDate)

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

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

        const eventDate = (card.startDate === card.endDate)
        ? toShortDate(card.endDate)
        : toShortDate(card.startDate) + ' - ' + toShortDate(card.endDate)
    Severity: Major
    Found in src/shared/components/wall/PostCard.js and 3 other locations - About 1 hr to fix
    src/shared/components/HomeComponent.js on lines 35..37
    src/shared/components/PostDetailComponent.js on lines 292..294
    src/shared/components/addon/maps/marker.js on lines 66..68

    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

      renderCardProp (card) {
        return (
          <span>
            {at(PostPropArray(originLocaleName(this.props.defaultLocale)), card.prop)}
          </span>
    Severity: Minor
    Found in src/shared/components/wall/PostCard.js and 1 other location - About 50 mins to fix
    src/shared/components/PostDetailComponent.js on lines 129..135

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

    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

        if (eventStartYear && toYear(card.endDate) === toYear(new Date())) {
          eventEndYear = <Translate content="post.detail.this_year" />
        }
    Severity: Minor
    Found in src/shared/components/wall/PostCard.js and 1 other location - About 40 mins to fix
    src/shared/components/PostDetailComponent.js on lines 306..308

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

    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

                {eventStartYear && (
                  <span className="ui small grey label">
                    {eventStartYear}
                    { eventEndYear
                      && <Translate content="post.detail.start" /> }
    Severity: Minor
    Found in src/shared/components/wall/PostCard.js and 1 other location - About 35 mins to fix
    src/shared/components/PostDetailComponent.js on lines 346..352

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

    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

    Prop type object is forbidden
    Open

        data: PropTypes.object,

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

    Empty components are self-closing
    Open

            <div className="ui post card divider"></div>

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

    Expected indentation of 16 space characters but found 18.
    Open

                      {this.renderLocationInfo(card)}

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

    Expected indentation of 14 space characters but found 12.
    Open

                {eventEndYear && (

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

    Empty components are self-closing
    Open

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

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

    Empty components are self-closing
    Open

            <div className="ui post card divider"></div>

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

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

          <span>

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

    propType "data" is not required, but has no corresponding defaultProp declaration.
    Open

        data: PropTypes.object,

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

    Expected indentation of 14 space characters but found 12.
    Open

                {eventStartYear && (

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

    There are no issues that match your filters.

    Category
    Status