meteor/meteor

View on GitHub
packages/email/email.js

Summary

Maintainability
B
6 hrs
Test Coverage

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

const knownHostsTransport = function (settings = undefined, url = undefined) {
  let service, user, password;

  const hasSettings = settings && Object.keys(settings).length;

Severity: Minor
Found in packages/email/email.js - About 1 hr to fix

    Function getTransport has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    const getTransport = function () {
      const packageSettings = Meteor.settings.packages?.email || {};
      // We delay this check until the first call to Email.send, in case someone
      // set process.env.MAIL_URL in startup code. Then we store in a cache until
      // process.env.MAIL_URL changes.
    Severity: Minor
    Found in packages/email/email.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 sendAsync has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Email.sendAsync = async function (options) {
    
      const email = options.mailComposer ? options.mailComposer.mail : options;
    
      let send = true;
    Severity: Minor
    Found in packages/email/email.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if (
            (packageSettings.service && wellKnow(packageSettings.service)) ||
            (url && wellKnow(new URL(url).hostname)) ||
            wellKnow(url?.split(':')[0] || '')
          ) {
      Severity: Major
      Found in packages/email/email.js - About 1 hr to fix

        Function knownHostsTransport has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        const knownHostsTransport = function (settings = undefined, url = undefined) {
          let service, user, password;
        
          const hasSettings = settings && Object.keys(settings).length;
        
        
        Severity: Minor
        Found in packages/email/email.js - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function sendAsync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        Email.sendAsync = async function (options) {
        
          const email = options.mailComposer ? options.mailComposer.mail : options;
        
          let send = true;
        Severity: Minor
        Found in packages/email/email.js - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function makeTransport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const makeTransport = function (mailUrlString) {
          const mailUrl = new URL(mailUrlString);
        
          if (mailUrl.protocol !== 'smtp:' && mailUrl.protocol !== 'smtps:') {
            throw new Error(
        Severity: Minor
        Found in packages/email/email.js - About 25 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

        There are no issues that match your filters.

        Category
        Status