timhaley94/holdem

View on GitHub

Showing 21 of 80 total issues

File index.test.js has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const { Types: { ObjectId } } = require('mongoose');
const {
  hasEqualIds,
  expectThrows,
  expectEqualIds,
Severity: Minor
Found in server/src/domain/room/index.test.js - About 5 hrs to fix

    File index.test.js has 363 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const { Errors } = require('../../modules');
    const Hand = require('../hand');
    const Solver = require('./index');
    
    describe('Domain.Solver', () => {
    Severity: Minor
    Found in server/src/domain/solver/index.test.js - About 4 hrs to fix

      File index.js has 348 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const { Schema } = require('mongoose');
      const { Errors } = require('../../modules');
      const Utils = require('../../utils');
      const Card = require('../card');
      const Deck = require('../deck');
      Severity: Minor
      Found in server/src/domain/round/index.js - About 4 hrs to fix

        Function Sidebar has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Sidebar() {
          const requireData = useRouteMatch('/room');
          const [data, setData] = useUser();
          const [isOpen, setIsOpen] = useState(false);
        
        
        Severity: Major
        Found in client/src/components/Sidebar/index.js - About 3 hrs to fix

          Function Lobby has 83 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function Lobby() {
            const [isCopied, setIsCopied] = useState(false);
            const copyRef = useRef(null);
          
            const [{ id: userId }] = useUser();
          Severity: Major
          Found in client/src/components/Lobby/index.js - About 3 hrs to fix

            Function Chat has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function Chat() {
              const { messages, sendMessage } = useRoom();
              const [value, setValue] = useState('');
              const [isShiftDown, setIsShiftDown] = useState(false);
              const bottomRef = useRef(null);
            Severity: Major
            Found in client/src/components/Chat/index.js - About 2 hrs to fix

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

              export function chunkBy(array, fn) {
                const { chunks, chunk } = (
                  array.reduce(
                    (acc, curr) => {
                      const key = fn(curr);
              Severity: Minor
              Found in client/src/utils.js - About 2 hrs to fix

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

                function useUserSync() {
                  const [{
                    id,
                    name,
                    avatarId,
                Severity: Minor
                Found in client/src/state/user.js - About 1 hr to fix

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

                  function Rooms() {
                    const { push } = useHistory();
                    const { rooms } = useRooms();
                  
                    if (!rooms) {
                  Severity: Minor
                  Found in client/src/components/Rooms/index.js - About 1 hr to fix

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

                    function distributeWinnings(round) {
                      const hands = (
                        round.players
                          .filter((player) => !player.hasFolded)
                          .reduce(
                    Severity: Minor
                    Found in server/src/domain/round/index.js - About 1 hr to fix

                      Function Player has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function Player() {
                        const [{ id: userId }] = useUser();
                        const { round } = useRound();
                      
                        const p = (
                      Severity: Minor
                      Found in client/src/components/Player/index.js - About 1 hr to fix

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

                        function allocate(hands, wagers, awarded = {}) {
                          const [head, ...losers] = hands;
                          const winners = (
                            Array.isArray(head)
                              ? head
                        Severity: Minor
                        Found in server/src/domain/solver/index.js - About 1 hr to fix

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

                          function create() {
                            const emitter = new EventEmitter();
                          
                            const listen = (fn) => emitter.addListener(globalName, fn);
                            const unlisten = (fn) => emitter.removeListener(globalName, fn);
                          Severity: Minor
                          Found in server/src/modules/listener/index.js - About 1 hr to fix

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

                            async function Socket(server) {
                              const io = IO(server, {
                                origins: '*:*',
                                serveClient: false,
                                pingInterval: config.socket.pingInterval,
                            Severity: Minor
                            Found in server/src/api/socket/index.js - About 1 hr to fix

                              Function reducer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function reducer(state, action) {
                                switch (action.type) {
                                  case PUSH:
                                    return {
                                      ...state,
                              Severity: Minor
                              Found in client/src/hooks/useArrayState.js - About 1 hr to fix

                                Function App has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function App() {
                                  return (
                                    <StateProvider>
                                      <Router>
                                        <Sidebar />
                                Severity: Minor
                                Found in client/src/components/App/index.js - About 1 hr to fix

                                  Function Chat has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function Chat() {
                                    const { messages, sendMessage } = useRoom();
                                    const [value, setValue] = useState('');
                                    const [isShiftDown, setIsShiftDown] = useState(false);
                                    const bottomRef = useRef(null);
                                  Severity: Minor
                                  Found in client/src/components/Chat/index.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 tieIndexes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function tieIndexes(shape) {
                                    const { indexes } = shape.reduce(
                                      (acc, val, i) => {
                                        if (i < shape.length - 1) {
                                          return {
                                  Severity: Minor
                                  Found in server/src/domain/hand/index.js - About 1 hr to fix

                                    Function take has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    async function take(model, id) {
                                      const key = lockName(model, id);
                                      const value = uuid();
                                    
                                      const get = async (n = retryCount) => {
                                    Severity: Minor
                                    Found in server/src/loaders/locks/__mocks__/index.js - About 1 hr to fix

                                      Function RoomProvider has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      function RoomProvider({ children }) {
                                        const { rooms } = useRooms();
                                        const [roomId, setRoomId] = useState(null);
                                        const { socket } = useSocket();
                                        const [{ token, id: userId }] = useUser();
                                      Severity: Minor
                                      Found in client/src/state/room.js - About 55 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language