elninotech/uppload

View on GitHub

Showing 72 of 92 total issues

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

              this.lang.services &&
              this.lang.services[service.name] &&
              this.lang.services[service.name].title
                ? this.lang.services[service.name].title
                : service.name
Severity: Major
Found in src/uppload.ts and 1 other location - About 2 hrs to fix
src/uppload.ts on lines 390..394

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

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

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

                translate(`services.${this.name}.placeholder`) ||
                translate("services.microlink.placeholder", [
                  translate(`services.${this.name}.title`) || this.name,
                  translate(`services.${this.name}.type`) ||
                    translate("services.microlink.type"),
    Severity: Major
    Found in src/helpers/microlink.ts and 1 other location - About 2 hrs to fix
    src/helpers/microlink.ts on lines 29..34

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

    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

                translate(`services.${this.name}.label`) ||
                translate("services.microlink.label", [
                  translate(`services.${this.name}.title`) || this.name,
                  translate(`services.${this.name}.type`) ||
                    translate("services.microlink.type"),
    Severity: Major
    Found in src/helpers/microlink.ts and 1 other location - About 2 hrs to fix
    src/helpers/microlink.ts on lines 37..42

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

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

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

          if (file)
            params.next({
              blob: file,
              size: file.size,
              type: file.type,
      Severity: Major
      Found in src/services/local.ts and 1 other location - About 1 hr to fix
      src/services/local.ts on lines 87..96

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

      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

          if (file)
            params.next({
              blob: file,
              size: file.size,
              type: file.type,
      Severity: Major
      Found in src/services/local.ts and 1 other location - About 1 hr to fix
      src/services/local.ts on lines 142..151

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

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

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

                  canvasToBlob(rotator.getCroppedCanvas()).then(blob => {
                    originalFile.blob = blob;
                    params.uppload.emitter.emit("process");
                    params.next(originalFile);
                  });
      Severity: Major
      Found in src/effects/rotate/index.ts and 1 other location - About 1 hr to fix
      src/effects/rotate/index.ts on lines 78..82

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

      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

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

                  canvasToBlob(rotator.getCroppedCanvas()).then(blob => {
                    originalFile.blob = blob;
                    params.uppload.emitter.emit("process");
                    params.next(originalFile);
                  });
      Severity: Major
      Found in src/effects/rotate/index.ts and 1 other location - About 1 hr to fix
      src/effects/rotate/index.ts on lines 54..58

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

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

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

              this.emitter.on("process", () => {
                const loader =
                  this.container.querySelector<HTMLDivElement>(".processing-loader");
                if (loader) loader.classList.remove("visible");
              });
          Severity: Major
          Found in src/uppload.ts and 1 other location - About 1 hr to fix
          src/uppload.ts on lines 82..86

          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

              this.emitter.on("processing", () => {
                const loader =
                  this.container.querySelector<HTMLDivElement>(".processing-loader");
                if (loader) loader.classList.add("visible");
              });
          Severity: Major
          Found in src/uppload.ts and 1 other location - About 1 hr to fix
          src/uppload.ts on lines 87..91

          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

          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 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 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
                Severity
                Category
                Status
                Source
                Language