joendres/nextcloud-filelink

View on GitHub

Showing 30 of 34 total issues

Function handleFormData has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

async function handleFormData() {

    sanitizeInput();

    // If user typed new password, username or URL the token is likely not valid any more
Severity: Minor
Found in src/prefspane/management.js - About 6 hrs 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 updateCapabilities has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    async updateCapabilities() {
        const data = await this._doApiCall(apiUrlCapabilities);
        if (!data._failed && data.capabilities) {
            // Don't test data.capabilities.files_sharing.api_enabled because the next line contains it all
            // Is public sharing enabled?
Severity: Minor
Found in src/lib/cloudconnection.js - About 4 hrs 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 handleFormData has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function handleFormData() {

    sanitizeInput();

    // If user typed new password, username or URL the token is likely not valid any more
Severity: Major
Found in src/prefspane/management.js - About 4 hrs to fix

    File cloudconnection.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    //#region  Configurable options and useful constants
    const apiUrlBase = "ocs/v1.php";
    const apiUrlUserInfo = "/cloud/users/";
    const apiUrlUserID = "/cloud/user";
    const apiUrlShares = "/apps/files_sharing/api/v1/shares";
    Severity: Minor
    Found in src/lib/cloudconnection.js - About 3 hrs to fix

      File management.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const accountId = new URL(location.href).searchParams.get("accountId");
      const ncc = new CloudConnection(accountId);
      
      loadFormData()
          .then(updateHeader)
      Severity: Minor
      Found in src/prefspane/management.js - About 2 hrs to fix

        Function updateCapabilities has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async updateCapabilities() {
                const data = await this._doApiCall(apiUrlCapabilities);
                if (!data._failed && data.capabilities) {
                    // Don't test data.capabilities.files_sharing.api_enabled because the next line contains it all
                    // Is public sharing enabled?
        Severity: Major
        Found in src/lib/cloudconnection.js - About 2 hrs to fix

          Function updateCloudInfo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async function updateCloudInfo() {
                  let answer = await ncc.updateUserId();
                  ncc.laststatus = null;
                  if (answer._failed) {
                      // If login failed, we might be using an app token which requires a lowercase user name
          Severity: Minor
          Found in src/prefspane/management.js - About 1 hr to fix

            Function updateFreeSpaceInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                async updateFreeSpaceInfo() {
                    let spaceRemaining = -1;
                    let spaceUsed = -1;
            
                    const data = await this._doApiCall(apiUrlUserInfo + this.userId);
            Severity: Minor
            Found in src/lib/cloudconnection.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 showErrors has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function showErrors() {
                if (ncc.laststatus) {
                    popup.error(ncc.laststatus);
                } else if (false === ncc.public_shares_enabled) {
                    popup.error('sharing_off');
            Severity: Minor
            Found in src/prefspane/management.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 updateStatusDisplay has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function updateStatusDisplay(uploads) {
                // Remove extra rows
                while (status_lines.rows.length > uploads.size) {
                    status_lines.deleteRow(-1);
                }
            Severity: Minor
            Found in src/progress/progress.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 _doApiCall has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async _doApiCall(suburl, method = 'GET', additional_headers = undefined, body = undefined) {
                    let url;
                    if (suburl.startsWith(this.serverUrl)) {
                        url = suburl;
                    } else {
            Severity: Minor
            Found in src/lib/cloudconnection.js - About 1 hr to fix

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

                  async _doUpload(uploadId, fileName, fileObject) {
                      // Is the file bigger than the maximum size for WebDAV?
                      attachmentStatus.get(uploadId).set_status('checkingsize');
                      if (fileObject.size > DAV_MAX_FILE_SIZE) {
                          attachmentStatus.get(uploadId).fail();
              Severity: Minor
              Found in src/lib/davuploader.js - About 1 hr to fix

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

                    async _doUpload(uploadId, fileName, fileObject) {
                        // Is the file bigger than the maximum size for WebDAV?
                        attachmentStatus.get(uploadId).set_status('checkingsize');
                        if (fileObject.size > DAV_MAX_FILE_SIZE) {
                            attachmentStatus.get(uploadId).fail();
                Severity: Minor
                Found in src/lib/davuploader.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 _doApiCall has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    async _doApiCall(suburl, method = 'GET', additional_headers = undefined, body = undefined) {
                        let url;
                        if (suburl.startsWith(this.serverUrl)) {
                            url = suburl;
                        } else {
                Severity: Minor
                Found in src/lib/cloudconnection.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 fill_status_row has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function fill_status_row(status, row) {
                    status_lines.rows[row].cells[0].textContent = status.filename;
                
                    const status_cell = status_lines.rows[row].cells[1];
                    if (status.error) {
                Severity: Minor
                Found in src/progress/progress.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 updateGauge has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function updateGauge() {
                    freespaceGauge.style.visibility = "hidden";
                    // Only show gauge if relevant form data match the account data
                    if (username.value === ncc.username && serverUrl.value === ncc.serverUrl) {
                        let theAccount = await messenger.cloudFile.getAccount(accountId);
                Severity: Minor
                Found in src/prefspane/management.js - About 1 hr to fix

                  Function fill_status_row has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function fill_status_row(status, row) {
                      status_lines.rows[row].cells[0].textContent = status.filename;
                  
                      const status_cell = status_lines.rows[row].cells[1];
                      if (status.error) {
                  Severity: Minor
                  Found in src/progress/progress.js - About 1 hr to fix

                    Function getCapabilities has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            async function getCapabilities() {
                                await ncc.updateCapabilities();
                                if (true === ncc.public_shares_enabled) {
                                    checkEnforcedExpiry();
                                    checkEnforcedDLPassword();
                    Severity: Minor
                    Found in src/prefspane/management.js - About 1 hr to fix

                      Function _xhrUpload has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async _xhrUpload(uploadId, path, data) {
                              let url = this._serverurl;
                              url += this._davUrl;
                              url += utils.encodepath(path);
                      
                      
                      Severity: Minor
                      Found in src/lib/davuploader.js - About 1 hr to fix

                        Function uploadFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async uploadFile(uploadId, fileName, fileObject) {
                                const upload_status = new Status(fileName);
                                attachmentStatus.set(uploadId, upload_status);
                        
                                upload_status.set_status('preparing');
                        Severity: Minor
                        Found in src/lib/cloudconnection.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language