elninotech/uppload

View on GitHub

Showing 72 of 92 total issues

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

          Function constructor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(apiKey: string) {
              super({
                apiKey,
                name: "pexels",
                icon: `<svg aria-hidden="true" viewbox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"><path d="M21 0h-4v255l72 1h71v-35l1-35 4-1a97 97 0 0053-33 81 81 0 0013-22l7-22v-3-23-2l-1-3v-2a95 95 0 00-42-60l-3-3-13-6a98 98 0 00-30-6H21zm130 37a85 85 0 008 1l11 5a57 57 0 0131 62c-5 23-23 41-45 45l-20 1h-12v68H53v-91l1-91h97z" fill="#000" fill-rule="nonzero"/></svg>`,
          Severity: Minor
          Found in src/services/search/pexels.ts - About 1 hr to fix

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

                      ready() {
                        canvasToBlob(cropper.getCroppedCanvas(), type).then(blob => {
                          originalFile.blob = blob;
                          params.next(originalFile);
                        });
            Severity: Major
            Found in src/effects/crop/index.ts and 1 other location - About 1 hr to fix
            src/effects/crop/index.ts on lines 104..109

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

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

              clickPhoto(params: IHandlersParams) {
                this.canvas = document.createElement("canvas");
                const video = params.uppload.container.querySelector(
                  "video.camera-stream"
                ) as HTMLVideoElement | null;
            Severity: Minor
            Found in src/services/camera.ts - About 1 hr to fix

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

                        cropend() {
                          canvasToBlob(cropper.getCroppedCanvas(), type).then(blob => {
                            originalFile.blob = blob;
                            params.next(originalFile);
                          });
              Severity: Major
              Found in src/effects/crop/index.ts and 1 other location - About 1 hr to fix
              src/effects/crop/index.ts on lines 98..103

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

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

                private getEffectsNavbar() {
                  return `<div class="effects-continue">
                  <button class="effects-continue--cancel">${translate("cancel")}</button>
                </div><div class="effects-tabs"><div class="effects-tabs-flow">
                    ${this.effects
              Severity: Minor
              Found in src/uppload.ts - About 1 hr to fix

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

                    return `
                      <div class="uppload-hue-image">
                        <img style="width: 20px" alt="" src="${image}">
                      </div>
                      <div class="settings">
                Severity: Major
                Found in src/helpers/filter.ts and 1 other location - About 1 hr to fix
                src/effects/rotate/index.ts on lines 25..35

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

                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

                    return `
                      <div class="uppload-rotating-element">
                        <img style="width: 20px" alt="" src="${image}">
                      </div>
                      <div class="settings">
                Severity: Major
                Found in src/effects/rotate/index.ts and 1 other location - About 1 hr to fix
                src/helpers/filter.ts on lines 28..38

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

                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 showHelp has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  showHelp(url: string) {
                    this.emitter.emit("help", url);
                    const aside = this.container.querySelector("aside");
                    if (aside) aside.style.display = "none";
                    const section = this.container.querySelector("section");
                Severity: Minor
                Found in src/uppload.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 render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  private render() {
                    return `
                      ${this.error ? `<div class="uppload-error">${this.error}</div>` : ""}
                      ${
                        this.activeEffect
                Severity: Minor
                Found in src/uppload.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 compressImage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                export const compressImage = (
                  file: Blob,
                  settings: IUpploadSettings
                ): Promise<Blob> =>
                  new Promise(resolve => {
                Severity: Minor
                Found in src/helpers/elements.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 constructor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  constructor(apiKey: string) {
                    super({
                      apiKey,
                      name: "unsplash",
                      icon: `<svg aria-hidden="true" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"><path d="M81 113v72h94v-72h81v143H0V113h81zM175 0v71H81V0h94z" fill="#000" fill-rule="evenodd"/></svg>`,
                Severity: Minor
                Found in src/services/search/unsplash.ts - About 1 hr to fix

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

                    private renderActiveEffect(file: IUpploadFile) {
                      const activeEffects = this.effects.filter(
                        effect => effect.name === this.activeEffect
                      );
                      if (!activeEffects.length) {
                  Severity: Minor
                  Found in src/uppload.ts - About 1 hr to fix

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

                          const linkFunction = (e: Event) => {
                            const service = link.getAttribute("data-uppload-service");
                            if (service) {
                              this.navigate(service);
                              const serviceDiv = this.container.querySelector(
                    Severity: Minor
                    Found in src/uppload.ts - About 1 hr to fix

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

                            translate(`services.${this.name}.button`) ||
                            translate(
                              "services.microlink.button",
                              translate(`services.${this.name}.title`) || this.name
                            )
                      Severity: Minor
                      Found in src/helpers/microlink.ts and 1 other location - About 50 mins to fix
                      src/helpers/microlink.ts on lines 58..62

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

                      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}.loading`) ||
                            translate(
                              "services.microlink.loading",
                              translate(`services.${this.name}.title`) || this.name
                            ) ||
                      Severity: Minor
                      Found in src/helpers/microlink.ts and 1 other location - About 50 mins to fix
                      src/helpers/microlink.ts on lines 47..51

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

                      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

                        off(type: string, handler: (event?: any) => void) {
                          return this.emitter.off(type, handler);
                        }
                      Severity: Minor
                      Found in src/uppload.ts and 1 other location - About 40 mins to fix
                      src/uppload.ts on lines 862..864

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

                      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