rooey/chromeos-filesystem-onedrive

View on GitHub

Showing 27 of 31 total issues

File onedrive_client.js has 864 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 2 days to fix

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

'use strict';

// Constants

const FILE_SYSTEM_ID = 'onedrivefs';
Severity: Major
Found in src/scripts/onedrive_fs.js - About 1 day to fix

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

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

Function authorize has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    authorize(successCallback, errorCallback) {
        this.access_token_ = this.getTokenFromCookie('access');
        if (this.access_token_) {
            console.log('already good');
            successCallback();
Severity: Major
Found in src/scripts/onedrive_client.js - About 2 hrs to fix

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

    assignEventHandlers() {
        console.log('Start: 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

Function refreshToken has 60 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: Major
Found in src/scripts/onedrive_client.js - About 2 hrs to fix

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

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

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

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

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

    getMetadata(path, successCallback, errorCallback) {
        console.log('PATH: ');
        console.log(path);
        if (path === '/') {
            console.log('path is === /');
Severity: Minor
Found in src/scripts/onedrive_client.js - About 1 hr to fix

Function mount has 47 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

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

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

Function createEventHandler has 39 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

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

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

    createOrDeleteEntry(operation, path, successCallback, errorCallback) {
        var url = "https://graph.microsoft.com/v1.0/me/drive/root";
        var data = JSON.stringify({
            path: path
        });
Severity: Minor
Found in src/scripts/onedrive_client.js - About 1 hr to fix

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

Function doCopyEntry has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    doCopyEntry(operation, sourcePath, targetPath, successCallback, errorCallback) {
        var sourceLastSlashPos = sourcePath.lastIndexOf("/");
        var sourceDir = sourcePath.substring(0, sourceLastSlashPos);
        var targetLastSlashPos = targetPath.lastIndexOf("/");
        var targetDir = targetPath.substring(0, targetLastSlashPos);
Severity: Minor
Found in src/scripts/onedrive_client.js - About 1 hr to fix
Severity
Category
Status
Source
Language