hexlet-codebattle/codebattle

View on GitHub

Showing 197 of 680 total issues

Function Tournament has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function Tournament({ waitingRoomMachine }) {
  const dispatch = useDispatch();

  const searchParams = useSearchParams();

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 updateGameHistoryState has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const updateGameHistoryState = nextRecordId => (dispatch, getState) => {
  const state = getState();
  const records = selectors.playbookRecordsSelector(state);
  const nextRecord = parse(records[nextRecordId]) || {};

Severity: Minor
Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.js - About 1 hr to fix

    Function clearGameListeners has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const clearGameListeners = () => {
        if (currentGameChannel) {
          currentGameChannel.off(channelTopics.editorDataTopic, refs[0]);
          currentGameChannel.off(channelTopics.userStartCheckTopic, refs[1]);
          currentGameChannel.off(channelTopics.userCheckCompleteTopic, refs[2]);
    Severity: Minor
    Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.js - About 1 hr to fix

      Function GamesHeatmap has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function GamesHeatmap() {
        const [activities, setActivities] = useState(null);
      
        const dispatch = useDispatch();
      
      

        Function GameResult has a Cognitive Complexity of 12 (exceeds 5 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));

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

        const initGameChannel = (gameRoomMachine, waitingRoomMachine, currentChannel) => dispatch => {
          const onJoinFailure = payload => {
            gameRoomMachine.send('REJECT_LOADING_GAME', { payload });
            gameRoomMachine.send('FAILURE_JOIN', { payload });
            window.location.reload();
        Severity: Minor
        Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.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 TimerContainer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function TimerContainer({
         time, mode, timeoutSeconds, gameStateName,
        }) {
          const { mainService, taskService } = useContext(RoomContext);
          const roomMachineState = useMachineStateSelector(mainService, roomStateSelector);

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

        function BuilderActions({
          validExamples,
          clearSuggests,
        }) {
          const dispatch = useDispatch();

        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 initTournamentChannel has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const initTournamentChannel = waitingRoomMachine => dispatch => {
          const onJoinFailure = () => {
            window.location.reload();
          };
        
        

          Function Notifications has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function Notifications() {
            const { mainService } = useContext(RoomContext);
            const roomMachineState = useMachineStateSelector(mainService, roomStateSelector);
          
            const { tournamentId } = useSelector(selectors.gameStatusSelector);

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

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

              Function handleSubmit has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const handleSubmit = useCallback(() => {
                  setError();
                  setState(LoadingStatusCodes.LOADING);
              
                  const onError = err => {

                Function getTitleByRoundType has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const getTitleByRoundType = (type, playersCount) => {
                  switch (type) {
                    case RoundTypes.one:
                      return 'Round 1';
                    case RoundTypes.two: {

                  Function establishChat has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const establishChat = () => dispatch => {
                    const oldChannel = channel;
                    const camelizeKeysAndDispatch = actionCreator => data => dispatch(actionCreator(camelizeKeys(data)));
                  
                    oldChannel.join().receive('ok', data => {
                  Severity: Minor
                  Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Chat.js - About 1 hr to fix

                    Function TaskDescriptionModal has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const TaskDescriptionModal = NiceModal.create(() => {
                      const dispatch = useDispatch();
                    
                      const modal = useModal(ModalCodes.taskDescriptionModal);
                    
                    

                      Function UserSettings has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function UserSettings() {
                        const [notification, setNotification] = useState(notifications.empty);
                        const settings = useSelector(userSettingsSelector);
                        const dispatch = useDispatch();
                      
                      

                        Method main has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        fun main(args: Array<String>) {
                          var oldOut: PrintStream = System.out
                          var executionResults: ArrayList<AssertResult> = ArrayList<AssertResult>()
                        
                          try {
                        Severity: Minor
                        Found in services/app/apps/runner/dockers/kotlin/check/checker.kt - About 1 hr to fix

                          Function useEvent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const useEvent = (name, handler, target = defaultTarget, options) => {
                              useEffect(() => {
                                  if (!handler) {
                                      return;
                                  }
                          Severity: Minor
                          Found in services/app/apps/codebattle/assets/js/widgets/utils/useEvent.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 SignatureForm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function SignatureForm({ signature, handleEdit }) {
                            const types = useMemo(() => resolveSignatureToTypes(signature), [signature]);
                          
                            const handleSelect = useCallback((newType, nestedIndex) => {
                              const newTypes = types.map((type, index) => (index === nestedIndex ? newType : type));

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

                          const TaskParamsModal = NiceModal.create(({
                            taskService,
                            mode: defaultMode = 'none',
                            action = 'none',
                          }) => {

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language