timhaley94/holdem

View on GitHub

Showing 80 of 80 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      it('solves basic problem', () => {
        expectSolution(
          {
            charlie: fullHouse(),
            mac: twoPair(),
Severity: Major
Found in server/src/domain/solver/index.test.js and 2 other locations - About 1 hr to fix
server/src/domain/solver/index.test.js on lines 193..207
server/src/domain/solver/index.test.js on lines 209..223

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 63.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      it('handles first place tie', () => {
        expectSolution(
          {
            charlie: fullHouse(),
            mac: fullHouse(),
Severity: Major
Found in server/src/domain/solver/index.test.js and 2 other locations - About 1 hr to fix
server/src/domain/solver/index.test.js on lines 52..66
server/src/domain/solver/index.test.js on lines 209..223

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 63.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it('returns true if bankroll is zero', () => {
              const p = Purse.create();
              p.bankroll = 0;
        
              expect(
        Severity: Major
        Found in server/src/domain/purse/index.test.js and 1 other location - About 1 hr to fix
        server/src/domain/purse/index.test.js on lines 166..173

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            it('returns false if bankroll is zero', () => {
              const p = Purse.create();
              p.bankroll = 0;
        
              expect(
        Severity: Major
        Found in server/src/domain/purse/index.test.js and 1 other location - About 1 hr to fix
        server/src/domain/purse/index.test.js on lines 177..184

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            expect(
              mapFind(
                [
                  { value: 3 },
                  { value: 1 },
        Severity: Major
        Found in server/src/utils/mapFind/index.test.js and 1 other location - About 1 hr to fix
        server/src/utils/mapFind/index.test.js on lines 5..14

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            expect(
              mapFind(
                [
                  { value: 3 },
                  { value: 4 },
        Severity: Major
        Found in server/src/utils/mapFind/index.test.js and 1 other location - About 1 hr to fix
        server/src/utils/mapFind/index.test.js on lines 18..27

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 61.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    it('throws otherwise', async () => {
                      await expectThrows(
                        () => Room.retrieve({ id: ObjectId().toString() }),
                        Errors.NotFound,
                      );
                Severity: Minor
                Found in server/src/domain/room/index.test.js and 1 other location - About 55 mins to fix
                server/src/domain/room/index.test.js on lines 111..116

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 54.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    it('throws otherwise', async () => {
                      await expectThrows(
                        () => Room.exists({ id: ObjectId().toString() }),
                        Errors.NotFound,
                      );
                Severity: Minor
                Found in server/src/domain/room/index.test.js and 1 other location - About 55 mins to fix
                server/src/domain/room/index.test.js on lines 126..131

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 54.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

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

                function Sidebar() {
                  const requireData = useRouteMatch('/room');
                  const [data, setData] = useUser();
                  const [isOpen, setIsOpen] = useState(false);
                
                
                Severity: Minor
                Found in client/src/components/Sidebar/index.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

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                module.exports = {
                  exists,
                  list,
                  retrieve,
                  create,
                Severity: Major
                Found in server/src/domain/room/index.js and 2 other locations - About 50 mins to fix
                server/src/domain/card/index.js on lines 36..45
                server/src/domain/stage/index.js on lines 33..42

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 52.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                module.exports = {
                  SUITS,
                  RANKS,
                  schema,
                  all,
                Severity: Major
                Found in server/src/domain/card/index.js and 2 other locations - About 50 mins to fix
                server/src/domain/room/index.js on lines 283..292
                server/src/domain/stage/index.js on lines 33..42

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 52.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language