open-wa/whatsapp-button

View on GitHub

Showing 21 of 21 total issues

Function runtime has a Cognitive Complexity of 232 (exceeds 5 allowed). Consider refactoring.
Open

var runtime = (function (exports) {
  "use strict";

  var Op = Object.prototype;
  var hasOwn = Op.hasOwnProperty;

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

var runtime = (function (exports) {
  "use strict";

  var Op = Object.prototype;
  var hasOwn = Op.hasOwnProperty;

    File regenerator-runtime.de2e6a3a74a500cae72a3cab1a403efc.js has 500 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Copyright (c) 2014-present, Facebook, Inc.
     *
     * This source code is licensed under the MIT license found in the
     * LICENSE file in the root directory of this source tree.

      Function styles has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static get styles() {
          return css`
            :host {
              display: flex;
              flex-direction: column;
      Severity: Major
      Found in src/WhatsappButton.ts - About 2 hrs to fix

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

            this.appLink = `${appPre}${
              this.invitecode
                ? `code=${this.invitecode}`
                : `phone=${this.dialcode}${this.phone}&text=${encodeURIComponent(
                    this.text
        Severity: Major
        Found in src/WhatsappButton.ts and 1 other location - About 2 hrs to fix
        src/WhatsappButton.ts on lines 185..191

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

        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

            this.link = `${pre}${
              this.invitecode
                ? `${this.invitecode}`
                : `phone=${this.dialcode}${this.phone}&text=${encodeURIComponent(
                    this.text
        Severity: Major
        Found in src/WhatsappButton.ts and 1 other location - About 2 hrs to fix
        src/WhatsappButton.ts on lines 192..198

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

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

          function makeInvokeMethod(innerFn, self, context) {
            var state = GenStateSuspendedStart;
        
            return function invoke(method, arg) {
              if (state === GenStateExecuting) {

          Function invoke has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              return function invoke(method, arg) {
                if (state === GenStateExecuting) {
                  throw new Error("Generator is already running");
                }
          
          

            Function maybeInvokeDelegate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function maybeInvokeDelegate(delegate, context) {
                var method = delegate.iterator[context.method];
                if (method === undefined) {
                  // A .throw or .return when the delegate iterator has no .throw
                  // method always terminates the yield* loop.

              Function dispatchException has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  dispatchException: function(exception) {
                    if (this.done) {
                      throw exception;
                    }
              
              

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

                  function AsyncIterator(generator, PromiseImpl) {
                    function invoke(method, arg, resolve, reject) {
                      var record = tryCatch(generator[method], generator, arg);
                      if (record.type === "throw") {
                        reject(record.arg);

                  Function loadingDialog has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    loadingDialog() {
                      if (this.shadowRoot) {
                        this.shadowRoot.innerHTML += `<vaadin-dialog >
                      </vaadin-dialog>`;
                        const dialog: any = this.shadowRoot.querySelector('vaadin-dialog') as any;
                  Severity: Minor
                  Found in src/WhatsappButton.ts - 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 firstUpdated has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    firstUpdated() {
                      this.label = this.label || this.invitecode ? 'Join Group!' : `Let's chat`;
                      this.phone = this.phone || ``;
                      this.text = this.text || `Hi!`;
                      const pre = this.invitecode
                  Severity: Minor
                  Found in src/WhatsappButton.ts - About 1 hr to fix

                    Function loadingDialog has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      loadingDialog() {
                        if (this.shadowRoot) {
                          this.shadowRoot.innerHTML += `<vaadin-dialog >
                        </vaadin-dialog>`;
                          const dialog: any = this.shadowRoot.querySelector('vaadin-dialog') as any;
                    Severity: Minor
                    Found in src/WhatsappButton.ts - About 1 hr to fix

                      Function firstUpdated has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        firstUpdated() {
                          this.label = this.label || this.invitecode ? 'Join Group!' : `Let's chat`;
                          this.phone = this.phone || ``;
                          this.text = this.text || `Hi!`;
                          const pre = this.invitecode
                      Severity: Minor
                      Found in src/WhatsappButton.ts - About 55 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

                      Avoid deeply nested control flow statements.
                      Open

                                  if (this.prev < entry.catchLoc) {
                                    return handle(entry.catchLoc, true);
                                  }

                        Avoid deeply nested control flow statements.
                        Open

                                  } else if (hasFinally) {
                                    if (this.prev < entry.finallyLoc) {
                                      return handle(entry.finallyLoc);
                                    }
                        
                        

                          Function async has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {

                            Avoid too many return statements within this function.
                            Open

                                  return info;

                              Avoid too many return statements within this function.
                              Open

                                            return handle(entry.finallyLoc);
                                Severity
                                Category
                                Status
                                Source
                                Language