notifme/notifme-sdk

View on GitHub

Showing 333 of 333 total issues

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

              return (0, _request["default"])("https://api.twilio.com/2010-04-01/Accounts/".concat(this.accountSid, "/Calls.json"), {
                method: 'POST',
                headers: {
                  Authorization: "Basic ".concat(this.apiKey),
                  'User-Agent': 'notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'
Severity: Major
Found in lib/providers/voice/twilio.js and 1 other location - About 1 hr to fix
lib/providers/sms/twilio.js on lines 62..69

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

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

              return (0, _request["default"])("https://api.twilio.com/2010-04-01/Accounts/".concat(this.accountSid, "/Messages.json"), {
                method: 'POST',
                headers: {
                  Authorization: "Basic ".concat(this.apiKey),
                  'User-Agent': 'notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'
Severity: Major
Found in lib/providers/sms/twilio.js and 1 other location - About 1 hr to fix
lib/providers/voice/twilio.js on lines 78..85

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

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

    const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${this.accountSid}/Calls.json`, {
      method: 'POST',
      headers: {
        Authorization: `Basic ${this.apiKey}`,
        'User-Agent': 'notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'
Severity: Major
Found in src/providers/voice/twilio.js and 1 other location - About 1 hr to fix
src/providers/sms/twilio.js on lines 27..34

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

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

    if (response.ok) {
      return responseBody.data
    } else {
      const error = responseBody.data
      throw new Error(Object.keys(error).map((key) => `${key}: ${error[key]}`).join(', '))
Severity: Major
Found in src/providers/sms/callr.js and 1 other location - About 1 hr to fix
src/providers/sms/infobip.js on lines 36..41

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

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

    const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${this.accountSid}/Messages.json`, {
      method: 'POST',
      headers: {
        Authorization: `Basic ${this.apiKey}`,
        'User-Agent': 'notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'
Severity: Major
Found in src/providers/sms/twilio.js and 1 other location - About 1 hr to fix
src/providers/voice/twilio.js on lines 48..55

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

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 send has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async send (request: EmailRequestType): Promise<string> {
    const { id, userId, from, replyTo, subject, html, text, headers, to, cc, bcc, attachments } =
      request.customize ? (await request.customize(this.id, request)) : request
    const form = new FormData()
    form.append('from', from)
Severity: Minor
Found in src/providers/email/mailgun.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 send has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async send (request: SmsRequestType): Promise<string> {
    const { appKey, consumerKey, account, host } = this.credentials
    const timestamp = Math.round(Date.now() / 1000)

    // Documentation: https://api.ovh.com/console/#/sms/%7BserviceName%7D/jobs#POST
Severity: Minor
Found in src/providers/sms/ovh.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 _callee$ has 39 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: Minor
Found in lib/providers/email/notificationCatcher.js - About 1 hr to fix

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

              attachments: attachments.map(({ contentType, filename, content }) =>
                ({
                  type: contentType,
                  filename,
                  content: (typeof content === 'string' ? Buffer.from(content) : content).toString('base64')
    Severity: Major
    Found in src/providers/email/sendgrid.js and 1 other location - About 1 hr to fix
    src/providers/email/sparkpost.js on lines 38..43

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

    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

              attachments: (attachments || []).map(({ contentType, filename, content }) =>
                ({
                  type: contentType,
                  name: filename,
                  data: (typeof content === 'string' ? Buffer.from(content) : content).toString('base64')
    Severity: Major
    Found in src/providers/email/sparkpost.js and 1 other location - About 1 hr to fix
    src/providers/email/sendgrid.js on lines 42..47

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

    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 _callee has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
            var _ref, subscription, title, rest;
            return _regenerator["default"].wrap(function _callee$(_context) {
              while (1) switch (_context.prev = _context.next) {
                case 0:
    Severity: Minor
    Found in lib/providers/webpush/notificationCatcher.js - About 1 hr to fix

      Function Sender has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function Sender(channels, providers, strategies) {
          var _this = this;
          (0, _classCallCheck2["default"])(this, Sender);
          this.channels = channels;
          this.providers = providers;
      Severity: Minor
      Found in lib/sender.js - About 1 hr to fix

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

              var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                var _ref, registrationToken, title, rest;
                return _regenerator["default"].wrap(function _callee$(_context) {
                  while (1) switch (_context.prev = _context.next) {
                    case 0:
        Severity: Minor
        Found in lib/providers/push/notificationCatcher.js - About 1 hr to fix

          Function _callee$ has 37 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: Minor
          Found in lib/providers/whatsapp/notificationCatcher.js - About 1 hr to fix

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

                  var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                    var _ref, to, from, url;
                    return _regenerator["default"].wrap(function _callee$(_context) {
                      while (1) switch (_context.prev = _context.next) {
                        case 0:
            Severity: Minor
            Found in lib/providers/voice/notificationCatcher.js - About 1 hr to fix

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

                    var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                      var _ref, registrationToken, rest, result;
                      return _regenerator["default"].wrap(function _callee$(_context) {
                        while (1) switch (_context.prev = _context.next) {
                          case 0:
              Severity: Minor
              Found in lib/providers/push/adm.js - About 1 hr to fix

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

                      var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                        var _ref, registrationToken, rest, result;
                        return _regenerator["default"].wrap(function _callee$(_context) {
                          while (1) switch (_context.prev = _context.next) {
                            case 0:
                Severity: Minor
                Found in lib/providers/push/apn.js - About 1 hr to fix

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

                        var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                          var _ref, registrationToken, rest, result;
                          return _regenerator["default"].wrap(function _callee$(_context) {
                            while (1) switch (_context.prev = _context.next) {
                              case 0:
                  Severity: Minor
                  Found in lib/providers/push/fcm.js - About 1 hr to fix

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

                          var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                            var _ref, to, from, text;
                            return _regenerator["default"].wrap(function _callee$(_context) {
                              while (1) switch (_context.prev = _context.next) {
                                case 0:
                    Severity: Minor
                    Found in lib/providers/sms/notificationCatcher.js - About 1 hr to fix

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

                            var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(request) {
                              var _ref, registrationToken, rest, result;
                              return _regenerator["default"].wrap(function _callee$(_context) {
                                while (1) switch (_context.prev = _context.next) {
                                  case 0:
                      Severity: Minor
                      Found in lib/providers/push/wns.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language