meteor/meteor

View on GitHub
packages/ddp-rate-limiter/ddp-rate-limiter-tests.js

Summary

Maintainability
F
3 days
Test Coverage

File ddp-rate-limiter-tests.js has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { Accounts } from 'meteor/accounts-base';
import { RATE_LIMIT_NUM_CALLS, RATE_LIMIT_INTERVAL_TIME_MS } from './ddp-rate-limiter-tests-common';

Severity: Minor
Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js - About 4 hrs to fix

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

      function (test, expect) {
        Meteor.call('getLastRateLimitEvent', expect((error, result) => {
          test.isFalse(result.reply.allowed);
          test.isTrue(result.reply.timeToReset < RATE_LIMIT_INTERVAL_TIME_MS + 100);
          test.equal(result.reply.numInvocationsLeft, 0);
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 1 other location - About 6 hrs to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 94..107

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

    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

      function (test, expect) {
        Meteor.call(
          'getLastRateLimitEvent',
          expect((error, result) => {
            test.isTrue(result.reply.allowed);
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 1 other location - About 6 hrs to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 118..128

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

    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 9 locations. Consider refactoring.
    Open

      function (test, expect) {
        Meteor.logout(expect((error) => {
          test.equal(error, undefined);
          test.equal(Meteor.user(), null);
        }));
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 8 other locations - About 1 hr to fix
    packages/accounts-password/email_tests.js on lines 51..56
    packages/accounts-password/email_tests.js on lines 64..69
    packages/accounts-password/email_tests.js on lines 113..118
    packages/accounts-password/email_tests.js on lines 126..131
    packages/accounts-password/email_tests.js on lines 255..260
    packages/accounts-password/email_tests.js on lines 306..311
    packages/accounts-password/email_tests.js on lines 321..326
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 16..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 60.

    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 9 locations. Consider refactoring.
    Open

      function (test, expect) {
        Meteor.logout(expect((error) => {
          test.equal(error, undefined);
          test.equal(Meteor.user(), null);
        }));
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 8 other locations - About 1 hr to fix
    packages/accounts-password/email_tests.js on lines 51..56
    packages/accounts-password/email_tests.js on lines 64..69
    packages/accounts-password/email_tests.js on lines 113..118
    packages/accounts-password/email_tests.js on lines 126..131
    packages/accounts-password/email_tests.js on lines 255..260
    packages/accounts-password/email_tests.js on lines 306..311
    packages/accounts-password/email_tests.js on lines 321..326
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 304..309

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        // After removing rule, subscriptions are no longer rate limited.
        Meteor.call('removeRuleFromDDPRateLimiter', this.ruleId,
          expect((error, result) => {
            test.equal(result, true);
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 45 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 72..79
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 132..139
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 158..165

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        // Cleanup
        Meteor.call('removeRuleFromDDPRateLimiter', this.ruleId,
          expect((error, result) => {
            test.equal(result, true);
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 45 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 132..139
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 158..165
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 194..201

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        // Cleanup
        Meteor.call('removeRuleFromDDPRateLimiter', this.ruleId,
          expect((error, result) => {
            test.equal(result, true);
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 45 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 72..79
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 132..139
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 194..201

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        // Cleanup
        Meteor.call('removeRuleFromDDPRateLimiter', this.ruleId,
          expect((error, result) => {
            test.equal(result, true);
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 45 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 72..79
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 158..165
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 194..201

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

    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

      function (test, expect) {
        Meteor.call('removeRuleFromDDPRateLimiter', this.ruleId,
          expect((error, result) => {
            test.equal(result, true);
          }),
    Severity: Minor
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 1 other location - About 40 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 257..263

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

    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

      function (test, expect) {
        Meteor.call('removeRuleFromDDPRateLimiter', this.ruleId,
          expect((error, result) => {
            test.equal(result, true);
          }),
    Severity: Minor
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 1 other location - About 40 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 283..289

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        callFnMultipleTimesThenExpectResult(test, expect,
          Meteor.call.bind(Meteor, 'dummyMethod'),
          {
            expectedError: undefined,
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 35 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 49..58
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 234..243
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 273..282

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        callFnMultipleTimesThenExpectResult(test, expect,
          Meteor.call.bind(Meteor, 'dummyMethod'),
          {
            expectedError: undefined,
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 35 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 234..243
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 247..256
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 273..282

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        callFnMultipleTimesThenExpectResult(test, expect,
          Meteor.call.bind(Meteor, 'a-method-that-is-not-rate-limited'),
          {
            expectedError: undefined,
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 35 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 49..58
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 234..243
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 247..256

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

    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 4 locations. Consider refactoring.
    Open

      function (test, expect) {
        callFnMultipleTimesThenExpectResult(test, expect,
          Meteor.call.bind(Meteor, 'dummyMethod'),
          {
            expectedError: undefined,
    Severity: Major
    Found in packages/ddp-rate-limiter/ddp-rate-limiter-tests.js and 3 other locations - About 35 mins to fix
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 49..58
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 247..256
    packages/ddp-rate-limiter/ddp-rate-limiter-tests.js on lines 273..282

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

    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

    There are no issues that match your filters.

    Category
    Status