ginpei/potoshop

View on GitHub

Showing 42 of 42 total issues

File PaintCanvas.tsx has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Color } from 'csstype';
import * as React from 'react';
import { AnimationFrameId, appSpace, between, emptyPos, IPos, IPosPair, Ratio } from '../../misc';
import MultiPointerHandler from '../../services/MultiPointerHandler';
import './PaintCanvas.css';
Severity: Minor
Found in src/pages/paint/PaintCanvas.tsx - About 4 hrs to fix

    PaintCanvas has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PaintCanvas extends React.Component<IPaintCanvasProps, IPaintCanvasState> {
      protected refCanvas = React.createRef<HTMLCanvasElement>();
      protected tmPressing: AnimationFrameId = 0;
      protected lastPos: IPos = emptyPos;
      protected lined = false;
    Severity: Minor
    Found in src/pages/paint/PaintCanvas.tsx - About 4 hrs to fix

      File PaintPage.tsx has 302 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // import * as firebase from 'firebase';
      import { Color } from 'csstype';
      import * as React from 'react';
      import { connect } from 'react-redux';
      import BubbleButton from '../../components/BubbleButton';
      Severity: Minor
      Found in src/pages/paint/PaintPage.tsx - About 3 hrs to fix

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

          protected async fetchList (): Promise<image.IImageRecord[]> {
            if (this.currentUser) {
              this.setState({ loadingImages: true });
              const images = await image.fetchList(this.currentUser.uid);
              this.setState({ loadingImages: false });
        Severity: Major
        Found in src/pages/CreateNewPage.tsx and 1 other location - About 3 hrs to fix
        src/pages/HistoryPage.tsx on lines 90..100

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

        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

          protected async fetchList (): Promise<IImageRecord[]> {
            if (this.currentUser) {
              this.setState({ loadingImages: true });
              const images = await image.fetchList(this.currentUser.uid);
              this.setState({ loadingImages: false });
        Severity: Major
        Found in src/pages/HistoryPage.tsx and 1 other location - About 3 hrs to fix
        src/pages/CreateNewPage.tsx on lines 167..177

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

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

        export async function getOrientation (file: File): Promise<ExifOrientation> {
          // TODO check why this is called twice
        
          const jpeg = 0xffd8;
          const exifMarker = 0xffe1;
        Severity: Major
        Found in src/services/imageUtil.ts - About 3 hrs to fix

          PointerHandler has 25 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class PointerHandler {
            protected props: IPointerHandlerProps;
            protected state: IPointerHandlerState;
            protected el: HTMLElement | null = null;
            protected pointStartedPos: IPos = emptyPos;
          Severity: Minor
          Found in src/services/PointerHandler.ts - About 2 hrs to fix

            Function render has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public render () {
                const onChange = this.onChange.bind(this);
                const onSubmitNew = this.onSubmitNew.bind(this);
                const onFileChange = this.onFileChange.bind(this);
                const records = this.state.imageRecords;
            Severity: Major
            Found in src/pages/CreateNewPage.tsx - About 2 hrs to fix

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

                  if (file && imageUtil.isImageFile(file)) {
                    const stop = this.props.startProcessing();
                    try {
                      await this.loadImage(file);
                    } finally {
              Severity: Major
              Found in src/pages/UploadImagePage.tsx and 1 other location - About 2 hrs to fix
              src/pages/UploadImagePage.tsx on lines 128..138

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

              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

                  if (file && imageUtil.isImageFile(file)) {
                    const stop = this.props.startProcessing();
                    try {
                      await this.loadImage(file);
                    } finally {
              Severity: Major
              Found in src/pages/UploadImagePage.tsx and 1 other location - About 2 hrs to fix
              src/pages/UploadImagePage.tsx on lines 153..163

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

              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

              PaintPage has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class PaintPage extends React.Component<IPaintPagePros, IPaintPageState> {
                protected currentUser: firebase.User | null = null;
                protected elCanvas: HTMLCanvasElement | null = null;
                protected storageRef = firebase.storage().ref('v1-images');
                protected canvasType = '';
              Severity: Minor
              Found in src/pages/paint/PaintPage.tsx - About 2 hrs to fix

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

                function applyImageOrientation (image: HTMLImageElement, orientation: ExifOrientation): Promise<HTMLImageElement> {
                  const width = image.naturalWidth;
                  const height = image.naturalHeight;
                
                  const canvas = document.createElement('canvas');
                Severity: Minor
                Found in src/services/imageUtil.ts - About 1 hr to fix

                  Function render has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public render () {
                      const s = this.state;
                      const onEditClick = this.onEditClick.bind(this);
                      const onScaleChange = this.onScaleChange.bind(this);
                      const onFileChange = this.onFileChange.bind(this);
                  Severity: Minor
                  Found in src/pages/UploadImagePage.tsx - About 1 hr to fix

                    Function getOrientation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export async function getOrientation (file: File): Promise<ExifOrientation> {
                      // TODO check why this is called twice
                    
                      const jpeg = 0xffd8;
                      const exifMarker = 0xffe1;
                    Severity: Minor
                    Found in src/services/imageUtil.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 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public render () {
                        return (
                          <div className="PaintPage">
                            {!this.state.imageLoading && <PaintCanvas
                              height={this.state.height}
                    Severity: Minor
                    Found in src/pages/paint/PaintPage.tsx - About 1 hr to fix

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

                        public render () {
                          const records = this.state.imageRecords;
                      
                          return (
                            <div className="HistoryPage">
                      Severity: Minor
                      Found in src/pages/HistoryPage.tsx - About 1 hr to fix

                        Function calculateProperPos has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          protected calculateProperPos (pos: IPos): IPos {
                            const el = this.el.current;
                            if (!el || !el.offsetParent) {
                              throw new Error('Element has to be mounted');
                            }
                        Severity: Minor
                        Found in src/components/BubbleButton.tsx - About 1 hr to fix

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

                            public render () {
                              return (
                                <div className="HomePage">
                                  <AppHeader/>
                                  <div className="container" lang="ja">
                          Severity: Minor
                          Found in src/pages/HomePage.tsx - About 1 hr to fix

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

                              protected renderMainContent () {
                                return (
                                  <PaintMenuContent>
                                    <PaintMenuBody>
                                      <div className="PaintMenu-close">
                            Severity: Minor
                            Found in src/pages/paint/PaintMenu.tsx - About 1 hr to fix

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

                                public render () {
                                  const title = this.props.title || 'Sorry, something went wrong... X(';
                              
                                  const ignoreBlock = !this.props.onIgnore ? undefined : (
                                    <p className="ErrorOverlay-ignoreBlock">
                              Severity: Minor
                              Found in src/components/ErrorOverlay.tsx - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language