yasshi2525/RushHour

View on GitHub

Showing 224 of 224 total issues

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

          for (var i = 0; i < beforeOffset - afterOffset; i++) {
            var offset = i - Math.floor(num / 2) - 1;
            this.genChild(beforeChunk, offset);

            var offset = i + Math.floor(num / 2) + beforeOffset;
Severity: Major
Found in client/src/models/border.ts and 1 other location - About 2 hrs to fix
client/src/models/border.ts on lines 219..225

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

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

          for (var i = 0; i < afterOffset - beforeOffset; i++) {
            var offset = i + Math.floor(num / 2) + 1;
            this.genChild(beforeChunk, offset);

            var offset = i - Math.floor(num / 2) + beforeOffset;
Severity: Major
Found in client/src/models/border.ts and 1 other location - About 2 hrs to fix
client/src/models/border.ts on lines 211..217

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

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

export default function() {
  const [opened, setOpened] = React.useState(false);
  const theme = useTheme();
  const classes = useStyles(theme);
  const isFullScreen = useMediaQuery(theme.breakpoints.down("sm"));
Severity: Minor
Found in client/src/components/UserSettings.tsx - 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 useDrag has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const useDrag = () => {
  const model = useContext(ModelContext);
  const reload = useReload();
  const [pressed, setPressed] = useState(false);
  const [start, setStart] = useState(ZERO);
Severity: Major
Found in client/src/common/scroll.ts - About 2 hrs to fix

    LineTask has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type LineTask struct {
        Base
        Persistence
    
        TaskType LineTaskType `gorm:"not null" json:"type"`
    Severity: Minor
    Found in entities/line_task.go - About 2 hrs to fix

      Function useTask has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const useTask = <I, O>(
        task: Task<I, O>,
        handlers?: TaskHandler<I, O>
      ): Handlers<I> => {
        const [, maintain] = useContext(OperationContext);
      Severity: Major
      Found in client/src/common/utils/task.ts - About 2 hrs to fix

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

          return useMemo(() => {
            if (error) {
              return <>{props.onError}</>;
            } else {
              return (
        Severity: Major
        Found in client/src/common/utils/provider_sync.tsx and 1 other location - About 2 hrs to fix
        client/src/common/utils/provider_async.tsx on lines 70..80

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

        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 useMemo(() => {
            if (error) {
              return <>{props.onError}</>;
            } else {
              return (
        Severity: Major
        Found in client/src/common/utils/provider_async.tsx and 1 other location - About 2 hrs to fix
        client/src/common/utils/provider_sync.tsx on lines 54..64

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

        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

                } else {
                  for (var s = +1; s > this.chunk.scale - nowChunk.scale; s--) {
                    if (!this.chScale[nowChunk.scale + s]) {
                      this.genChildren(getChunkByScale(nowChunk, s));
                    }
        Severity: Major
        Found in client/src/models/border.ts and 1 other location - About 2 hrs to fix
        client/src/models/border.ts on lines 184..190

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

        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 (zoom) {
                  for (var s = -1; s < this.chunk.scale - nowChunk.scale; s++) {
                    if (!this.chScale[nowChunk.scale + s]) {
                      this.genChildren(getChunkByScale(nowChunk, s));
                    }
        Severity: Major
        Found in client/src/models/border.ts and 1 other location - About 2 hrs to fix
        client/src/models/border.ts on lines 190..196

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

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

        export const usePinch = () => {
          const model = useContext(ModelContext);
          const [pressed, setPressed] = useState(false);
          const [start, setStart] = useState(ZERO);
          const [now, setNow] = useState(ZERO);
        Severity: Major
        Found in client/src/common/zoom.ts - About 2 hrs to fix

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

            {
              const xLen = Math.pow(2, xScale);
              const left = 0;
              const right = mapSize - xLen;
              x = x < left ? left : x > right ? right : x;
          Severity: Major
          Found in client/src/common/coord.tsx and 1 other location - About 2 hrs to fix
          client/src/common/coord.tsx on lines 120..126

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

          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

            {
              const yLen = Math.pow(2, yScale);
              const top = 0;
              const buttom = mapSize - yLen;
              y = y < top ? top : y > buttom ? buttom : y;
          Severity: Major
          Found in client/src/common/coord.tsx and 1 other location - About 2 hrs to fix
          client/src/common/coord.tsx on lines 113..119

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

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

          export const useSwipe = () => {
            const model = useContext(ModelContext);
            const reload = useReload();
            const [pressed, setPressed] = useState(false);
            const [start, setStart] = useState(ZERO);
          Severity: Major
          Found in client/src/common/scroll.ts - About 2 hrs to fix

            Function useCoord has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const useCoord = (): CoordState => {
              const [{ min_scale, max_scale }] = useContext(ConfigContext);
              const [w, h] = useContext(WindowContext);
              const pixi = useContext(PixiContext);
            
            
            Severity: Major
            Found in client/src/common/coord.tsx - About 2 hrs to fix

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

                    let avg = {
                      x: (this.from.current.x + this.to.current.x) / 2,
                      y: (this.from.current.y + this.to.current.y) / 2
                    };
              Severity: Major
              Found in client/src/models/rail.ts and 1 other location - About 2 hrs to fix
              client/src/models/pixi.ts on lines 110..113

              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

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

                  let center = {
                    x: this.app.renderer.width / this.app.renderer.resolution / 2,
                    y: this.app.renderer.height / this.app.renderer.resolution / 2
                  };
              Severity: Major
              Found in client/src/models/pixi.ts and 1 other location - About 2 hrs to fix
              client/src/models/rail.ts on lines 262..265

              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

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

              export default function(props: Attributes) {
                const [opened, setOpened] = React.useState(false);
                const theme = useTheme();
                const classes = useStyles(theme);
                const isFullScreen = useMediaQuery(theme.breakpoints.down("sm"));
              Severity: Minor
              Found in client/src/components/Register.tsx - 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 useCache has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              const useCache = <T>(
                onGrace: (key: string, data: T) => void = () => {},
                onExpired: (key: string, data: T) => void = () => {},
                activeTime: number = ACTIVE,
                graceTime: number = GRACE
              Severity: Minor
              Found in client/src/common/utils/cache.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

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

              func (o *Player) Init(m *Model) {
                  o.Base.Init(PLAYER, m)
                  o.RailNodes = make(map[uint]*RailNode)
                  o.RailEdges = make(map[uint]*RailEdge)
                  o.Stations = make(map[uint]*Station)
              Severity: Major
              Found in entities/player.go and 1 other location - About 2 hrs to fix
              entities/platform.go on lines 88..98

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

              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