elninotech/uppload

View on GitHub

Showing 35 of 92 total issues

File uppload.ts has 702 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { UpploadService } from "./service";
import { UpploadEffect } from "./effect";
import { setI18N, translate } from "./helpers/i18n";
import { compressImage, getElements, safeListen } from "./helpers/elements";
import { colorSVG } from "./helpers/assets";
Severity: Major
Found in src/uppload.ts - About 1 day to fix

    Uppload has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Uppload implements IUppload {
      services: UpploadService[] = [new DefaultService(), new UploadingService()];
      effects: UpploadEffect[] = [];
      isOpen = false;
      error?: string;
    Severity: Minor
    Found in src/uppload.ts - About 4 hrs to fix

      Function handlers has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private handlers() {
          const openFunction = () => this.open();
          const closeFunction = () => this.close();
      
          /**
      Severity: Major
      Found in src/uppload.ts - About 3 hrs to fix

        Function canvasToBlob has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        export const canvasToBlob = (
          canvas: HTMLCanvasElement,
          type?: string,
          quality?: number
        ): Promise<Blob> => {
        Severity: Minor
        Found in src/helpers/elements.ts - 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 update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          private update() {
            if (!this.container) return;
            this.hideHelp();
            if (this.settings.customClass)
              this.container.classList.add(this.settings.customClass);
        Severity: Minor
        Found in src/uppload.ts - 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 update has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private update() {
            if (!this.container) return;
            this.hideHelp();
            if (this.settings.customClass)
              this.container.classList.add(this.settings.customClass);
        Severity: Major
        Found in src/uppload.ts - About 2 hrs to fix

          Function getFile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            getFile(params: IHandlersParams, event: Event) {
              event.preventDefault();
              const files = (event.target as HTMLInputElement).files;
              let file: File | null = null;
              if (files) {
          Severity: Minor
          Found in src/services/local.ts - 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 dropHandler has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            dropHandler(params: IHandlersParams, event: DragEvent) {
              event.preventDefault();
              this.dragStop(params, event);
              let file: File | null = null; // getAsFile() returns File | null
              if (event.dataTransfer && event.dataTransfer.items) {
          Severity: Minor
          Found in src/services/local.ts - 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 update has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            update(params: IHandlersParams) {
              const waiting = params.uppload.container.querySelector(
                ".camera-waiting"
              ) as HTMLDivElement | null;
              if (waiting) {
          Severity: Minor
          Found in src/services/camera.ts - About 1 hr to fix

            Function update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              update(params: IHandlersParams) {
                const waiting = params.uppload.container.querySelector(
                  ".camera-waiting"
                ) as HTMLDivElement | null;
                if (waiting) {
            Severity: Minor
            Found in src/services/camera.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 flattenObject has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            export const flattenObject = (ob: any) => {
              const toReturn: any = {};
              for (const i in ob) {
                if (!ob.hasOwnProperty(i)) continue;
                if (typeof ob[i] == "object") {
            Severity: Minor
            Found in src/helpers/i18n.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 upload has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              upload(file: File | Blob): Promise<string> {
                this.emitter.emit("before-upload", file);
                return new Promise((resolve, reject) => {
                  this.navigate("uploading");
                  let upploadFile = blobToUpploadFile(file);
            Severity: Minor
            Found in src/uppload.ts - About 1 hr to fix

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

              export const canvasToBlob = (
                canvas: HTMLCanvasElement,
                type?: string,
                quality?: number
              ): Promise<Blob> => {
              Severity: Minor
              Found in src/helpers/elements.ts - About 1 hr to fix

                Function getNavbar has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private getNavbar(sidebar = false) {
                    return `<${sidebar ? "nav" : "div"} class="uppload-services">
                      ${this.services
                        .filter(service => !service.invisible)
                        .map(
                Severity: Minor
                Found in src/uppload.ts - About 1 hr to fix

                  Function getFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    getFile(params: IHandlersParams, event: Event) {
                      event.preventDefault();
                      const files = (event.target as HTMLInputElement).files;
                      let file: File | null = null;
                      if (files) {
                  Severity: Minor
                  Found in src/services/local.ts - About 1 hr to fix

                    Function cachedFetch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function cachedFetch<T>(
                      input: RequestInfo,
                      settings?: RequestInit
                    ): Promise<T> {
                      const storage = sessionStorage;
                    Severity: Minor
                    Found in src/helpers/http.ts - About 1 hr to fix

                      Function dropHandler has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        dropHandler(params: IHandlersParams, event: DragEvent) {
                          event.preventDefault();
                          this.dragStop(params, event);
                          let file: File | null = null; // getAsFile() returns File | null
                          if (event.dataTransfer && event.dataTransfer.items) {
                      Severity: Minor
                      Found in src/services/local.ts - About 1 hr to fix

                        Function compressImage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          new Promise(resolve => {
                            const imageURL = URL.createObjectURL(file);
                            const canvas = document.createElement("canvas");
                            const image = document.createElement("img");
                            const maxSize = settings.maxSize || [
                        Severity: Minor
                        Found in src/helpers/elements.ts - About 1 hr to fix

                          Function fitImageToContainer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const fitImageToContainer = (
                            params: IHandlersParams,
                            image: HTMLImageElement | HTMLVideoElement
                          ): Promise<void> => {
                            return new Promise(resolve => {
                          Severity: Minor
                          Found in src/helpers/elements.ts - About 1 hr to fix

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

                              private renderContainer() {
                                if (this.container)
                                  this.container.innerHTML = `
                                  <div class="uppload-modal">
                                    <div class="processing-loader"></div>
                            Severity: Minor
                            Found in src/uppload.ts - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language