shakacode/react-webpack-rails-tutorial

View on GitHub

Showing 41 of 41 total issues

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

  it('shows the author', () => {
    const component = renderIntoDocument(<Comment author="Frank" text="Hi!" />);

    const author = findRenderedDOMComponentWithClass(component, 'js-comment-author');
    expect(author.textContent).toEqual('Frank');
client/app/bundles/comments/components/CommentBox/CommentList/Comment/Comment.spec.jsx on lines 26..31

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

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

            <li className={classNames({ 'bg-yellow-100': pathname === paths.RAILS_PATH })}>
              <a
                className="px-2 py-4 w-full inline-block text-gray-500 hover:text-gray-700"
                href={paths.RAILS_PATH}
              >
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 68..75
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 76..83
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 84..91
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 100..107

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

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

            <li className={classNames({ 'bg-yellow-100': pathname === paths.NO_ROUTER_PATH })}>
              <a
                className="px-2 py-4 w-full inline-block text-gray-500 hover:text-gray-700"
                href={paths.NO_ROUTER_PATH}
              >
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 76..83
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 84..91
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 92..99
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 100..107

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

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

            <li className={classNames({ 'bg-yellow-100': pathname === paths.SIMPLE_REACT_PATH })}>
              <a
                className="px-2 py-4 w-full inline-block text-gray-500 hover:text-gray-700"
                href={paths.SIMPLE_REACT_PATH}
              >
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 68..75
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 84..91
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 92..99
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 100..107

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

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

            <li className={classNames({ 'bg-yellow-100': pathname === paths.RESCRIPT_PATH })}>
              <a
                className="px-2 py-4 w-full inline-block text-gray-500 hover:text-gray-700"
                href={paths.RESCRIPT_PATH}
              >
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 68..75
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 76..83
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 84..91
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 92..99

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

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

            <li className={classNames({ 'bg-yellow-100': pathname === paths.STIMULUS_PATH })}>
              <a
                className="px-2 py-4 w-full inline-block text-gray-500 hover:text-gray-700"
                href={paths.STIMULUS_PATH}
              >
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 68..75
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 76..83
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 92..99
client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx on lines 100..107

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

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

      case 0:
        comment = {
          author: ReactDOM.findDOMNode(this.refs.horizontalAuthorNode).value,
          text: ReactDOM.findDOMNode(this.refs.horizontalTextNode).value,
        };
client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx on lines 47..52

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

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

      case 1:
        comment = {
          author: ReactDOM.findDOMNode(this.refs.stackedAuthorNode).value,
          text: ReactDOM.findDOMNode(this.refs.stackedTextNode).value,
        };
client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx on lines 41..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 63.

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

Method create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @comment = Comment.new(comment_params)

    respond_to do |format|
      if @comment.save
Severity: Minor
Found in app/controllers/comments_controller.rb - About 1 hr 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 errorWarning has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  errorWarning() {
    const { error, cssTransitionGroupClassNames } = this.props;

    // If there is no error, there is nothing to add to the DOM
    if (!error.error) return null;

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

      render() {
        const { handleSetLocale, locale, intl } = this.props;
        const { formatMessage } = intl;
        const cssTransitionGroupClassNames = {
          enter: css.elementEnter,

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

        render() {
          const { $$comments, cssTransitionGroupClassNames } = this.props;
          const commentNodes = $$comments.map(($$comment, index) => {
            const nodeRef = React.createRef(null);
            return (

        Function exports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function (api) {
          const defaultConfigFunc = require('shakapacker/package/babel/preset.js');
          const resultConfig = defaultConfigFunc(api);
          const isProductionEnv = api.env('production');
        
        
        Severity: Minor
        Found in babel.config.js - About 1 hr to fix

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

                      <li>
                        <Link to="/react-router" className={({ isActive }) => (isActive ? ' activated' : '')}>
                          Test React Router ('/react-router')
                        </Link>
                      </li>
          Severity: Minor
          Found in client/app/bundles/comments/layout/Layout.jsx and 1 other location - About 55 mins to fix
          client/app/bundles/comments/layout/Layout.jsx on lines 24..28

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

          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

                      <li>
                        <Link to="/react-router/redirect" className={({ isActive }) => (isActive ? ' activated' : '')}>
                          Test Redirect (url to '/react-router/redirect' which goes to root '/')
                        </Link>
                      </li>
          Severity: Minor
          Found in client/app/bundles/comments/layout/Layout.jsx and 1 other location - About 55 mins to fix
          client/app/bundles/comments/layout/Layout.jsx on lines 19..23

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

          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

          Function resetText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            resetText() {
              const inputAuthor = this.commentAuthorTarget;
              const inputText = this.commentTextTarget;
              const alertDiv = this.alertDivTarget;
              const errorList = this.errorListTarget;
          Severity: Minor
          Found in client/app/controllers/comments_controller.js - About 35 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

          Avoid too many return statements within this function.
          Open

                return $$state;
          Severity: Major
          Found in client/app/bundles/comments/reducers/commentsReducer.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return $$state.merge({
                    locale,
                  });
            Severity: Major
            Found in client/app/bundles/comments/reducers/commentsReducer.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return $$state.merge({
                      isSaving: true,
                    });
              Severity: Major
              Found in client/app/bundles/comments/reducers/commentsReducer.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return $$state.merge({
                        submitCommentError: error,
                        isSaving: false,
                      });
                Severity: Major
                Found in client/app/bundles/comments/reducers/commentsReducer.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language