hexlet-codebattle/codebattle

View on GitHub

Showing 200 of 693 total issues

Function editorsPanelOptionsSelector has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export const editorsPanelOptionsSelector = (viewMode, roomMachineState) => state => {
  const currentUserId = currentUserIdSelector(state);
  const editorsMode = editorsModeSelector(state);
  const theme = editorsThemeSelector(state);

Severity: Minor
Found in services/app/apps/codebattle/assets/js/widgets/selectors/index.js - About 2 hrs 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 GameActionButton has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function GameActionButton({
  type = 'table', game, currentUserId, isGuest, isOnline,
}) {
  const gameUrl = makeGameUrl(game.id);
  const gameUrlJoin = makeGameUrl(game.id, 'join');

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

File CreateGameDialog.test.jsx has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';

import { configureStore, combineReducers } from '@reduxjs/toolkit';
import { render, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

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

    function ResetPassword() {
      const [isSend, setIsSend] = useState(false);
    
      const formik = useFormik({
        initialValues: {

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

        const onJoinSuccess = () => {
          channel.addListener(channelTopics.invitesInitTopic, data => {
            if (data.invites.length > 0) {
              const message = getSystemMessage({ text: `You have (${data.invites.length}) invites to battle. Check ` });
              setTimeout(() => dispatch(actions.newChatMessage(message)), 100);
      Severity: Major
      Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Invite.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

          if (
            player.score > opponent.score
            || (player.score === opponent.score
              && player.winMatches.length > opponent.winMatches.length)
            || (player.winMatches.length === opponent.winMatches.length

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

            render() {
              const { recordsCount, mainEvents, roomMachineState } = this.props;
          
              const {
                isEnabled, direction, handlerPosition, lastIntent, nextRecordId,

            Consider simplifying this complex logical expression.
            Open

              if (
                player.score > opponent.score
                || (player.score === opponent.score
                  && player.winMatches.length > opponent.winMatches.length)
                || (player.winMatches.length === opponent.winMatches.length

              Function AnimationModal has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const AnimationModal = NiceModal.create(() => {
                const modal = useModal(ModalCodes.gameResultModal);
              
                const players = useSelector(state => gamePlayersSelector(state));
                const currentUserId = useSelector(state => currentUserIdSelector(state));

                Function onJoinSuccess has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const onJoinSuccess = response => {
                    if (response.error) {
                      console.error(response.error);
                      return;
                    }
                Severity: Minor
                Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.js - About 1 hr to fix

                  Function addCursorListeners has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const addCursorListeners = (params, onChangePosition, onChangeSelection) => {
                    const {
                      roomMode,
                      userId,
                    } = params;
                  Severity: Minor
                  Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.js - About 1 hr to fix

                    Function handleUserJoined has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const handleUserJoined = data => {
                        const {
                          state, startsAt, timeoutSeconds, langs, players, task,
                        } = data;
                    
                    
                    Severity: Minor
                    Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.js - About 1 hr to fix

                      Function fetchState has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const fetchState = currentUserId => dispatch => {
                        const channelName = 'lobby';
                        channel.setupChannel(channelName);
                      
                        const camelizeKeysAndDispatch = actionCreator => data => dispatch(actionCreator(camelizeKeys(data)));
                      Severity: Minor
                      Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Lobby.js - About 1 hr to fix

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

                        function TournamentChat() {
                          const currentUserIsAdmin = useSelector(selectors.currentUserIsAdminSelector);
                          const messages = useSelector(selectors.chatMessagesSelector);
                          const users = useSelector(selectors.chatUsersSelector);
                          const isOnline = useSelector(selectors.chatChannelStateSelector);

                          Method Test has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static void Test(bool success)
                              {
                                TextWriter oldOut = Console.Out;
                                StringBuilder sb = new StringBuilder();
                                TextWriter newOut = new StringWriter(sb);
                          Severity: Minor
                          Found in services/app/apps/runner/dockers/csharp/check/Checker.cs - About 1 hr to fix

                            Function TournamentGameCreatePanel has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function TournamentGameCreatePanel({
                              players,
                              matches,
                              taskList = [],
                              currentRoundPosition,

                            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 TournamentMatchBadge has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function TournamentMatchBadge({ matchState, isWinner, currentUserIsPlayer }) {
                              const title = useMemo(() => {
                                switch (matchState) {
                                  case MatchStatesCodes.pending:
                                    return 'Next';

                            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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const run = function run(args = []) {
                              let output = '';
                              const fakeStream = new Writable();
                              const myConsole = new Console(fakeStream);
                            
                            
                            Severity: Minor
                            Found in services/app/apps/runner/dockers/js/checker.js - 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 GameRoomLockPanel has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function GameRoomLockPanel() {
                              const dispatch = useDispatch();
                            
                              const inputRef = useRef(null);
                            
                            

                              Function GameResult has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function GameResult() {
                                const currentUserId = useSelector(state => selectors.currentUserIdSelector(state));
                                const players = useSelector(state => selectors.gamePlayersSelector(state));
                                const isCurrentUserPlayer = hasIn(players, currentUserId);
                                const gameStatus = useSelector(state => selectors.gameStatusSelector(state));
                                Severity
                                Category
                                Status
                                Source
                                Language