shakacode/react-webpack-rails-tutorial

View on GitHub

Showing 19 of 41 total issues

Function NavigationBar has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function NavigationBar(props) {
  const { commentsCount, pathname } = props;

  const [isOpen, setIsOpen] = useState(false);

    File CommentForm.jsx has 316 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable react/no-find-dom-node, react/no-string-refs */
    import React from 'react';
    import PropTypes from 'prop-types';
    import ReactDOM from 'react-dom';
    import { CSSTransition, TransitionGroup } from 'react-transition-group';

      Function commentsReducer has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function commentsReducer($$state = $$initialState, action = null) {
        const { type, comment, comments, error, locale } = action;
      
        switch (type) {
          case actionTypes.FETCH_COMMENTS_SUCCESS: {
      Severity: Major
      Found in client/app/bundles/comments/reducers/commentsReducer.js - About 2 hrs to fix

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

          render() {
            let inputForm;
            switch (this.state.formMode) {
              case 0:
                inputForm = this.formHorizontal();

          Function formHorizontal has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            formHorizontal() {
              const { formatMessage } = this.props.intl;
              return (
                <div>
                  <hr />

            Function formStacked has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              formStacked() {
                const { formatMessage } = this.props.intl;
                return (
                  <div>
                    <hr />

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

                render() {
                  const { actions, data, intl } = this.props;
                  const { formatMessage } = intl;
                  const cssTransitionGroupClassNames = {
                    enter: css.elementEnter,
              Severity: Minor
              Found in client/app/bundles/comments/components/CommentBox/CommentBox.jsx - About 1 hr to fix

                Function formInline has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  formInline() {
                    const { formatMessage } = this.props.intl;
                    return (
                      <div>
                        <hr />

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

                          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({
                                    isFetching: 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({
                                      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({
                                        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({
                                          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