hexlet-codebattle/codebattle

View on GitHub

Showing 197 of 680 total issues

File TournamentAdmin.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import axios from 'axios';
import Gon from 'gon';
import { camelizeKeys, decamelizeKeys } from 'humps';
import compact from 'lodash/compact';
import groupBy from 'lodash/groupBy';

    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

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

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

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

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

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

                        function ExtensionPopup() {
                          const [modalShowing, setModalShowing] = useState(true);
                          const handleHide = () => { setModalShowing(false); };
                        
                          return (

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

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

                            export const checkTaskSolution = editorMachine => (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 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 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

                                Severity
                                Category
                                Status
                                Source
                                Language