anephenix/hub

View on GitHub

Showing 86 of 86 total issues

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

    describe('#hasBanRule', () => {
        after(async () => {
            await dataStore.clearBanRules();
        });
        const banRule = {
Severity: Major
Found in __tests__/lib/dataStores/redis.test.js and 1 other location - About 2 days to fix
__tests__/lib/dataStores/memory.test.js on lines 171..234

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 397.

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

    describe('#hasBanRule', () => {
        after(async () => {
            await memoryStore.clearBanRules();
        });
        const banRule = {
Severity: Major
Found in __tests__/lib/dataStores/memory.test.js and 1 other location - About 2 days to fix
__tests__/lib/dataStores/redis.test.js on lines 215..276

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 397.

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

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

// Dependencies
const assert = require('assert');
const { Hub, HubClient } = require('../../index');
const WebSocket = require('ws');
const { v4: uuidv4 } = require('uuid');
Severity: Major
Found in __tests__/lib/pubsub.test.js - About 2 days to fix

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

    // Dependencies
    const assert = require('assert');
    const { Hub, HubClient } = require('../../../index');
    const httpShutdown = require('http-shutdown');
    const { delay, delayUntil } = require('../../../helpers/delay');
    Severity: Minor
    Found in __tests__/lib/client/index.test.js - About 7 hrs to fix

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

              it('should only allow clients to connect if they have an allowed origin', async () => {
                  const hub = new Hub({ port: 8000, allowedOrigins: ['localhost:8000'] });
                  const server = httpShutdown(hub.server);
                  server.listen(8000);
                  const hubClient = new HubClient({ url: 'ws://localhost:8000' });
      Severity: Major
      Found in __tests__/lib/originCheck.test.js and 2 other locations - About 6 hrs to fix
      __tests__/lib/ipCheck.test.js on lines 22..34
      __tests__/lib/originCheck.test.js on lines 24..33

      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 157.

      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('should disconnect any clients that attempt to connect from an origin that is not in the allowed origins list', async () => {
                  const hub = new Hub({ port: 7000, allowedOrigins: ['localhost:4000'] });
                  const server = httpShutdown(hub.server);
                  server.listen(7000);
                  const hubClient = new HubClient({ url: 'ws://localhost:7000' });
      Severity: Major
      Found in __tests__/lib/originCheck.test.js and 2 other locations - About 6 hrs to fix
      __tests__/lib/ipCheck.test.js on lines 22..34
      __tests__/lib/originCheck.test.js on lines 35..44

      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 157.

      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('should disconnect any clients that attempt to connect from an ip address that is not in the allowed ip addresses list', async () => {
                  const hub = new Hub({
                      port: 7001,
                      allowedIpAddresses: ['151.101.0.81'],
                  });
      Severity: Major
      Found in __tests__/lib/ipCheck.test.js and 2 other locations - About 6 hrs to fix
      __tests__/lib/originCheck.test.js on lines 24..33
      __tests__/lib/originCheck.test.js on lines 35..44

      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 157.

      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

          describe('when allowedIPAddresses is an empty array', () => {
              it('should not close the connection to block the client', async () => {
                  const hub = new Hub({ port: 6001 });
                  const server = httpShutdown(hub.server);
                  server.listen(6001);
      Severity: Major
      Found in __tests__/lib/ipCheck.test.js and 1 other location - About 5 hrs to fix
      __tests__/lib/originCheck.test.js on lines 9..21

      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 151.

      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

          describe('when allowedOrigins is an empty array', () => {
      
              it('should not close the connection to block the client', async () => {
                  const hub = new Hub({ port: 6000 });
                  const server = httpShutdown(hub.server);
      Severity: Major
      Found in __tests__/lib/originCheck.test.js and 1 other location - About 5 hrs to fix
      __tests__/lib/ipCheck.test.js on lines 8..19

      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 151.

      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

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

          async hasBanRule(item) {
              const banRules = await this.getBanRules();
              const matchFilter = (b) => {
                  const keys = Object.keys(b).filter((x) => b[x]);
                  const matches = keys.map((k) => b[k] === item[k]);
      Severity: Major
      Found in lib/dataStores/redis.js and 1 other location - About 5 hrs to fix
      lib/dataStores/memory.js on lines 88..96

      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 138.

      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

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

          async hasBanRule(item) {
              const banRules = await this.getBanRules();
              const matchFilter = (b) => {
                  const keys = Object.keys(b).filter(x => b[x]);
                  const matches = keys.map(k => b[k] === item[k]);
      Severity: Major
      Found in lib/dataStores/memory.js and 1 other location - About 5 hrs to fix
      lib/dataStores/redis.js on lines 117..125

      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 138.

      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

          describe('#clearBanRules', () => {
              it('should remove all of the rules', async () => {
                  const banRule = {
                      clientId: 'xxx',
                      host: 'app.local',
      Severity: Major
      Found in __tests__/lib/dataStores/redis.test.js and 1 other location - About 4 hrs to fix
      __tests__/lib/dataStores/memory.test.js on lines 155..169

      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 133.

      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

          describe('#clearBanRules', () => {
              it('should remove all of the rules', async () => {
                  const banRule = {
                      clientId: 'xxx',
                      host: 'app.local',
      Severity: Major
      Found in __tests__/lib/dataStores/memory.test.js and 1 other location - About 4 hrs to fix
      __tests__/lib/dataStores/redis.test.js on lines 199..213

      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 133.

      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

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

      const assert = require('assert');
      const http = require('http');
      const https = require('https');
      const { Hub, HubClient } = require('../index');
      const httpShutdown = require('http-shutdown');
      Severity: Minor
      Found in __tests__/index.test.js - About 4 hrs to fix

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

                describe('when a ban rule is found for removal', () => {
                    it('should be removed from the list of ban rules, and return the ban rule that was removed', async () => {
                        const banRule = {
                            clientId: 'xxx',
                            host: 'app.local',
        Severity: Major
        Found in __tests__/lib/dataStores/memory.test.js and 1 other location - About 4 hrs to fix
        __tests__/lib/dataStores/redis.test.js on lines 318..331

        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 120.

        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

                describe('when a ban rule is found for removal', () => {
                    it('should be removed from the list of ban rules, and return the ban rule that was removed', async () => {
                        const banRule = {
                            clientId: 'xxx',
                            host: 'app.local',
        Severity: Major
        Found in __tests__/lib/dataStores/redis.test.js and 1 other location - About 4 hrs to fix
        __tests__/lib/dataStores/memory.test.js on lines 265..278

        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 120.

        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

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

        // Dependencies
        const assert = require('assert');
        const RedisDataStore = require('../../../lib/dataStores/redis');
        const { decode } = require('../../../lib/dataTransformer');
        const redisLib = require('redis');
        Severity: Minor
        Found in __tests__/lib/dataStores/redis.test.js - About 3 hrs to fix

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

                  describe('when the same rule has been added before', () => {
                      it('should not be added to the existing list of banRules', async () => {
                          const existingBanRules = await memoryStore.getBanRules();
                          assert.deepStrictEqual(existingBanRules, [banRule]);
                          await memoryStore.addBanRule(banRule);
          Severity: Major
          Found in __tests__/lib/dataStores/memory.test.js and 1 other location - About 3 hrs to fix
          __tests__/lib/dataStores/redis.test.js on lines 298..306

          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 99.

          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

                  describe('when the same rule has been added before', () => {
                      it('should not be added to the existing list of banRules', async () => {
                          const existingBanRules = await dataStore.getBanRules();
                          assert.deepStrictEqual(existingBanRules, [banRule]);
                          await dataStore.addBanRule(banRule);
          Severity: Major
          Found in __tests__/lib/dataStores/redis.test.js and 1 other location - About 3 hrs to fix
          __tests__/lib/dataStores/memory.test.js on lines 253..261

          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 99.

          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

                  describe('when the rule is new', () => {
                      it('should be added to the list of banRules', async () => {
                          const existingBanRules = await memoryStore.getBanRules();
                          assert.deepStrictEqual(existingBanRules, []);
                          await memoryStore.addBanRule(banRule);
          Severity: Major
          Found in __tests__/lib/dataStores/memory.test.js and 1 other location - About 3 hrs to fix
          __tests__/lib/dataStores/redis.test.js on lines 288..296

          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 98.

          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