jeansaad/hotel

View on GitHub

Showing 29 of 29 total issues

File group.js has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fs = require("fs");
const path = require("path");
const EventEmitter = require("events");
const url = require("url");
const once = require("once");
Severity: Minor
Found in src/daemon/group.js - About 3 hrs to fix

    Function add has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function add(param, opts = {}) {
      mkdirp.sync(serversDir);
    
      const cwd = opts.dir || process.cwd();
      const id = opts.name ? domainify(opts.name) : getId(cwd);
    Severity: Minor
    Found in src/cli/servers.js - 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 getKeydownListener has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      public getKeydownListener(store: Store) {
        if (this.keydownListener == null) {
          this.keydownListener = (event: KeyboardEvent) => {
            const selectedMonitor = store.monitors.get(store.selectedMonitorId);
            const isSelectedMonitorRunning = selectedMonitor?.status === RUNNING
    Severity: Minor
    Found in src/app/components/Content/index.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 add has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function add(param, opts = {}) {
      mkdirp.sync(serversDir);
    
      const cwd = opts.dir || process.cwd();
      const id = opts.name ? domainify(opts.name) : getId(cwd);
    Severity: Major
    Found in src/cli/servers.js - About 2 hrs to fix

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

        add(id, conf) {
          if (conf.target) {
            log(`Add target ${id}`);
            this._list[id] = conf;
            this._change();
      Severity: Major
      Found in src/daemon/group.js - About 2 hrs to fix

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

          handleConnect(req, socket, head) {
            if (req.headers.host) {
              const { host } = req.headers;
              const { id, hostname, port } = this.parseHost(host);
        
        
        Severity: Minor
        Found in src/daemon/group.js - 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 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public render() {
            const { store } = this.props
            const monitor = store.monitors.get(store.selectedMonitorId)
            return (
              <div
        Severity: Minor
        Found in src/app/components/Content/index.tsx - About 1 hr to fix

          Function handleUpgrade has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            handleUpgrade(req, socket, head) {
              if (req.headers.host) {
                const { host } = req.headers;
                const { id, port } = this.parseHost(host);
                const item = this.find(id);
          Severity: Minor
          Found in src/daemon/group.js - 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 (window.EventSource) {
              new window.EventSource('/_/events/output').onmessage = (event: IEvent) => {
                const data = JSON.parse(event.data)
                cb(data)
              }
          Severity: Major
          Found in src/app/api.ts and 1 other location - About 1 hr to fix
          src/app/api.ts on lines 10..22

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

          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 (window.EventSource) {
              new window.EventSource('/_/events').onmessage = (event: IEvent) => {
                const data = JSON.parse(event.data)
                cb(data)
              }
          Severity: Major
          Found in src/app/api.ts and 1 other location - About 1 hr to fix
          src/app/api.ts on lines 26..33

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

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

            public getKeydownListener(store: Store) {
              if (this.keydownListener == null) {
                this.keydownListener = (event: KeyboardEvent) => {
                  const selectedMonitor = store.monitors.get(store.selectedMonitorId);
                  const isSelectedMonitorRunning = selectedMonitor?.status === RUNNING
          Severity: Minor
          Found in src/app/components/Content/index.tsx - About 1 hr to fix

            Function handleConnect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              handleConnect(req, socket, head) {
                if (req.headers.host) {
                  const { host } = req.headers;
                  const { id, hostname, port } = this.parseHost(host);
            
            
            Severity: Minor
            Found in src/daemon/group.js - About 1 hr to fix

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

                spawn(cmd, opts = {}) {
                  const cleanAndExit = (code = 0) => {
                    servers.rm(opts);
                    this._exit(code);
                  };
              Severity: Minor
              Found in src/cli/run.js - About 1 hr to fix

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

                    function selectPrevMonitor() {
                      const { prev } = getCurrentMonitorState();
                      if (prev != null) {
                        store.selectMonitor(prev[0]);
                      }
                Severity: Minor
                Found in src/app/components/Nav/index.tsx and 1 other location - About 45 mins to fix
                src/app/components/Nav/index.tsx on lines 59..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 50.

                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

                    function selectNextMonitor() {
                      const { next } = getCurrentMonitorState();
                      if (next != null) {
                        store.selectMonitor(next[0]);
                      }
                Severity: Minor
                Found in src/app/components/Nav/index.tsx and 1 other location - About 45 mins to fix
                src/app/components/Nav/index.tsx on lines 52..57

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

                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

                  router.post(
                    "/:id/start",
                    group.exists.bind(group),
                    group.start.bind(group),
                    (req, res) => res.end()
                Severity: Minor
                Found in src/daemon/routers/api/servers.js and 1 other location - About 45 mins to fix
                src/daemon/routers/api/servers.js on lines 17..22

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

                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

                  router.post(
                    "/:id/stop",
                    group.exists.bind(group),
                    group.stop.bind(group),
                    (req, res) => res.end()
                Severity: Minor
                Found in src/daemon/routers/api/servers.js and 1 other location - About 45 mins to fix
                src/daemon/routers/api/servers.js on lines 10..15

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

                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

                Replace ········ with ······
                Open

                        isWildcardMatch: matcher.isMatch(str, `*.${h}`)
                Severity: Minor
                Found in src/daemon/group.js by eslint

                For more information visit Source: http://eslint.org/docs/rules/

                Delete ··
                Open

                      }));
                Severity: Minor
                Found in src/daemon/group.js by eslint

                For more information visit Source: http://eslint.org/docs/rules/

                Delete ··
                Open

                        isStrictMatch: matcher.isMatch(str, h),
                Severity: Minor
                Found in src/daemon/group.js by eslint

                For more information visit Source: http://eslint.org/docs/rules/

                Severity
                Category
                Status
                Source
                Language