notifme/notifme-sdk

View on GitHub
lib/providers/email/sparkpost.js

Summary

Maintainability
F
3 days
Test Coverage

Function value has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    value: function () {
      var _send = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
        var _ref, id, userId, from, replyTo, subject, html, text, headers, to, cc, bcc, attachments, response, responseBody, _responseBody$errors, firstError, message;
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
Severity: Major
Found in lib/providers/email/sparkpost.js - About 4 hrs to fix

    Function _callee has 109 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          var _send = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
            var _ref, id, userId, from, replyTo, subject, html, text, headers, to, cc, bcc, attachments, response, responseBody, _responseBody$errors, firstError, message;
            return _regenerator["default"].wrap(function _callee$(_context) {
              while (1) switch (_context.prev = _context.next) {
                case 0:
    Severity: Major
    Found in lib/providers/email/sparkpost.js - About 4 hrs to fix

      Function _callee$ has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              return _regenerator["default"].wrap(function _callee$(_context) {
                while (1) switch (_context.prev = _context.next) {
                  case 0:
                    if (!request.customize) {
                      _context.next = 6;
      Severity: Major
      Found in lib/providers/email/sparkpost.js - About 4 hrs to fix

        Function _objectSpread has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
        Severity: Minor
        Found in lib/providers/email/sparkpost.js - About 45 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 11 locations. Consider refactoring.
        Open

        function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
        Severity: Major
        Found in lib/providers/email/sparkpost.js and 10 other locations - About 7 hrs to fix
        lib/index.js on lines 29..29
        lib/providers/email/mandrill.js on lines 24..24
        lib/providers/email/sendgrid.js on lines 26..26
        lib/providers/notificationCatcherProvider.js on lines 21..21
        lib/providers/push/adm.js on lines 23..23
        lib/providers/push/wns.js on lines 23..23
        lib/providers/sms/callr.js on lines 23..23
        lib/providers/sms/clickatell.js on lines 22..22
        lib/providers/sms/nexmo.js on lines 22..22
        lib/sender.js on lines 27..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 176.

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

        function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
        Severity: Major
        Found in lib/providers/email/sparkpost.js and 11 other locations - About 3 hrs to fix
        lib/providers/email/mandrill.js on lines 23..23
        lib/providers/email/sendgrid.js on lines 25..25
        lib/providers/notificationCatcherProvider.js on lines 20..20
        lib/providers/push/adm.js on lines 22..22
        lib/providers/push/notificationCatcher.js on lines 27..27
        lib/providers/push/wns.js on lines 22..22
        lib/providers/sms/callr.js on lines 22..22
        lib/providers/sms/clickatell.js on lines 21..21
        lib/providers/sms/nexmo.js on lines 21..21
        lib/providers/webpush/notificationCatcher.js on lines 27..27
        lib/sender.js on lines 26..26

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

        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

                      message = (0, _keys["default"])(firstError).map(function (key) {
                        return "".concat(key, ": ").concat(firstError[key]);
                      }).join(', ');
        Severity: Major
        Found in lib/providers/email/sparkpost.js and 3 other locations - About 1 hr to fix
        lib/providers/email/mandrill.js on lines 129..131
        lib/providers/email/sendgrid.js on lines 142..144
        lib/providers/sms/infobip.js on lines 99..101

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

        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

                var _ref, id, userId, from, replyTo, subject, html, text, headers, to, cc, bcc, attachments, response, responseBody, _responseBody$errors, firstError, message;
        Severity: Major
        Found in lib/providers/email/sparkpost.js and 1 other location - About 1 hr to fix
        lib/providers/sms/ovh.js on lines 54..54

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

        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 EmailSparkPostProvider(config) {
            (0, _classCallCheck2["default"])(this, EmailSparkPostProvider);
            (0, _defineProperty2["default"])(this, "id", 'email-sparkpost-provider');
            this.apiKey = config.apiKey;
          }
        Severity: Major
        Found in lib/providers/email/sparkpost.js and 3 other locations - About 1 hr to fix
        lib/providers/email/mandrill.js on lines 27..31
        lib/providers/email/sendgrid.js on lines 29..33
        lib/providers/slack/slack.js on lines 20..24

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

        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

                          })), (0, _toConsumableArray2["default"])((bcc || []).map(function (email) {
                            return {
                              address: {
                                email: email,
                                header_to: to
        Severity: Minor
        Found in lib/providers/email/sparkpost.js and 1 other location - About 50 mins to fix
        lib/providers/email/sparkpost.js on lines 103..110

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

        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

                          }].concat((0, _toConsumableArray2["default"])((cc || []).map(function (email) {
                            return {
                              address: {
                                email: email,
                                header_to: to
        Severity: Minor
        Found in lib/providers/email/sparkpost.js and 1 other location - About 50 mins to fix
        lib/providers/email/sparkpost.js on lines 110..117

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

        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