hexlet-codebattle/codebattle

View on GitHub

Showing 200 of 693 total issues

Function checkTaskSolution has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const checkTaskSolution = editorService => (dispatch, getState) => {
  const state = getState();
  const currentUserId = selectors.currentUserIdSelector(state);
  const { text, lang } = selectors.getSolution(currentUserId)(state);
  const task = selectors.builderTaskSelector(state);
Severity: Minor
Found in services/app/apps/codebattle/assets/js/widgets/middlewares/Room.js - About 1 hr to fix

    Function Heatmap has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

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

      const initGameChannel = (gameRoomService, waitingRoomService) => dispatch => {
        const onJoinFailure = payload => {
          gameRoomService.send('REJECT_LOADING_GAME', { payload });
          gameRoomService.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 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 getTitleByRoundType has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

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

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

      const UserStats = ({ data, user: userInfo }) => {
        const dispatch = useDispatch();
      
        const activeGameId = data?.activeGameId;
        const avatarUrl = userInfo.avatarUrl || data?.user?.avatarUrl || '/assets/images/logo.svg';

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

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

          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 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 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, currentChannel) => dispatch => {
            const onJoinFailure = err => {
              console.error(err);
              // 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 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 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 CreateGameDialog has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function CreateGameDialog({ hideModal }) {
                          const dispatch = useDispatch();
                          const { gameOptions: givenGameOptions, opponentInfo } = useSelector(selectors.modalSelector);
                          const [opponent, setOpponent] = useState(opponentInfo);
                          const [chosenTask, setChosenTask] = useState(unchosenTask);

                        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