rooey/chromeos-filesystem-onedrive

View on GitHub

Showing 230 of 230 total issues

File onedrive_client.js has 816 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

let storedAppInfo = null;

let appInfo = {
Severity: Major
Found in src/scripts/onedrive_client.js - About 1 day to fix
  • Create a ticket

    File onedrive_fs.js has 501 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    // Constants
    // Use set DEBUG_ENABLED to true to enable verbose logging (alpha builds)
    const DEBUG_ENABLED = true;
    Severity: Major
    Found in src/scripts/onedrive_fs.js - About 1 day to fix
    • Create a ticket

      OneDriveClient has 45 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class OneDriveClient {
      
          // Constructor
      
          constructor(onedriveFS) {
      Severity: Minor
      Found in src/scripts/onedrive_client.js - About 6 hrs to fix
      • Create a ticket

        OneDriveFS has 43 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class OneDriveFS {
        
            // Constructor
        
            constructor() {
        Severity: Minor
        Found in src/scripts/onedrive_fs.js - About 5 hrs to fix
        • Create a ticket

          Function handleError has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              handleError(error, textStatus, errorThrown) {
                  const status = Number(error.status);
                  if (status === 404 || status === 409) {
                      console.debug(error);
                      this.errorCallback_('NOT_FOUND');
          Severity: Minor
          Found in src/scripts/http_fetcher.js - About 2 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 authorize has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              authorize(successCallback, errorCallback) {
                  this.access_token_ = this.getTokenFromCookie('access');
                  if (this.access_token_) {
                      successCallback();
                  }
          Severity: Major
          Found in src/scripts/onedrive_client.js - About 2 hrs to fix
          • Create a ticket

            Function assignEventHandlers has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                assignEventHandlers() {
                    chrome.alarms.onAlarm.addListener(alarm => {
                        if (alarm.name === 'onedrive_alarm') {
                            this.onAlarm(alarm);
                        }
            Severity: Major
            Found in src/scripts/onedrive_fs.js - About 2 hrs to fix
            • Create a ticket

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

              const background = () => {
                  if (!chrome.fileSystemProvider) {
                      console.log('There is no chrome.fileSystemProvider API. See you on ChromeOS!');
                      return;
                  }
              Severity: Major
              Found in src/scripts/background.js - About 2 hrs to fix
              • Create a ticket

                Consider simplifying this complex logical expression.
                Open

                            if (window.FormData &&
                                ((options.dataType && (options.dataType === 'binary')) ||
                                 (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) ||
                                                   (window.Blob && options.data instanceof Blob))))) {
                                return {
                Severity: Critical
                Found in src/scripts/onedrive_client.js - About 2 hrs to fix
                • Create a ticket

                  Function truncate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      truncate(filePath, length, successCallback, errorCallback) {
                          console.log('doing truncate');
                          const data = this.jsonStringify({
                              path: filePath
                          });
                  Severity: Minor
                  Found in src/scripts/onedrive_client.js - About 1 hr to fix
                  • Create a ticket

                    Function handleError has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        handleError(error, textStatus, errorThrown) {
                            const status = Number(error.status);
                            if (status === 404 || status === 409) {
                                console.debug(error);
                                this.errorCallback_('NOT_FOUND');
                    Severity: Minor
                    Found in src/scripts/http_fetcher.js - About 1 hr to fix
                    • Create a ticket

                      Function getMetadata has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          getMetadata(path, successCallback, errorCallback) {
                              this.onedrive_fs_.writeLog('debug', 'getMetadata path:', path);
                      
                              if (path === '/') {
                                  successCallback({
                      Severity: Minor
                      Found in src/scripts/onedrive_client.js - About 1 hr to fix
                      • Create a ticket

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

                            refreshToken(successCallback, errorCallback){
                                this.refresh_token_ = this.getTokenFromCookie('refresh');
                                var appInfo = this.getAppInfo();
                                var fileSystemId = 'onedrivefs://' + this.uid_;
                                //var thisvalue = this.onedrive_fs_.fileSystemId;
                        Severity: Minor
                        Found in src/scripts/onedrive_client.js - About 1 hr to fix
                        • Create a ticket

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

                              mount(successCallback, errorCallback) {
                                  const onedriveClient = new OneDriveClient(this);
                                  onedriveClient.authorize(() => {
                                      onedriveClient.getDriveData((driveInfo) => {
                                          onedriveClient.getUserInfo((userInfo) => {
                          Severity: Minor
                          Found in src/scripts/onedrive_fs.js - About 1 hr to fix
                          • Create a ticket

                            Function watchDirectory has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                watchDirectory(fileSystemId, onedriveClient, entryPath) {
                                    this.useOptions('useWatcher', use => {
                                        if (!use) {
                                            return;
                                        }
                            Severity: Minor
                            Found in src/scripts/onedrive_fs.js - About 1 hr to fix
                            • Create a ticket

                              Function createEventHandler has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  createEventHandler(callback) {
                                      return (options, successCallback, errorCallback) => {
                                          const fileSystemId = options.fileSystemId;
                                          const onedriveClient = this.getOneDriveClient(fileSystemId);
                                          if (!onedriveClient) {
                              Severity: Minor
                              Found in src/scripts/onedrive_fs.js - About 1 hr to fix
                              • Create a ticket

                                Function sendContents has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    sendContents(options, successCallback, errorCallback) {
                                        if (!options.hasMore) {
                                            successCallback();
                                        } else {
                                            var len = options.data.byteLength;
                                Severity: Minor
                                Found in src/scripts/onedrive_client.js - About 1 hr to fix
                                • Create a ticket

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

                                      MetadataCache.prototype.get = function(entryPath) {
                                          if (entryPath === "/") {
                                              return {
                                                  needFetch: true,
                                                  exists: true
                                  Severity: Minor
                                  Found in src/scripts/metadata_cache.js - About 1 hr to fix
                                  • Create a ticket

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

                                                const entryMetadata = {
                                                    isDirectory: ('folder' in result),
                                                    name: result.name,
                                                    size: result.size || 0,
                                                    modificationTime: result.lastModifiedDateTime ? new Date(result.lastModifiedDateTime) : new Date()
                                    Severity: Major
                                    Found in src/scripts/onedrive_client.js and 1 other location - About 1 hr to fix
                                    src/scripts/onedrive_client.js on lines 947..952

                                    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

                                                const entryMetadata = {
                                                    isDirectory: ('folder' in content),
                                                    name: content.name,
                                                    size: content.size || 0,
                                                    modificationTime: content.lastModifiedDateTime ? new Date(content.lastModifiedDateTime) : new Date()
                                    Severity: Major
                                    Found in src/scripts/onedrive_client.js and 1 other location - About 1 hr to fix
                                    src/scripts/onedrive_client.js on lines 326..331

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language