interlockjs/interlock

View on GitHub

Showing 22 of 34 total issues

Function createServer has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createServer (opts = {}) {
  const eventsUrl = opts.eventsUrl || "/ilk/events";
  const connections = {};
  let nextConnectionID = 0;

Severity: Major
Found in src/server/server.js - About 2 hrs to fix

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

    export const handler = argv => {
      const config = argv.config ? options.loadConfig(argv.config) : {};
      const logger = options.getLogger(argv.verbose);
    
      const compileOpts = options.getInterlockOpts(
    Severity: Minor
    Found in src/cli/ilk-server.js - About 1 hr to fix

      Function server has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const server = http.createServer((req, res) => {
          shouldRespond.then(() => { // eslint-disable-line max-statements
            const acceptType = req.headers.accept;
            let requestUrl = url.parse(req.url).pathname.toLowerCase();
            if (!(requestUrl in dynamicResources)) {
      Severity: Minor
      Found in src/server/server.js - About 1 hr to fix

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

        export function createServer (opts = {}) {
          const eventsUrl = opts.eventsUrl || "/ilk/events";
          const connections = {};
          let nextConnectionID = 0;
        
        
        Severity: Minor
        Found in src/server/server.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 transformModule has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default pluggable(function transformModule (module) {
          if (module.type !== "javascript") {
            throw new Error("Cannot transform non-JS module.  Please activate appropriate plugin.");
          }
          const babelUserConfig = this.opts.babelConfig || {};
        Severity: Minor
        Found in src/compile/modules/transform.js - About 1 hr to fix

          Function template has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function template (code) {
            let stack;
            try {
              throw new Error();
            } catch (error) {
          Severity: Minor
          Found in src/util/template.js - About 1 hr to fix

            Function parseModule has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default pluggable(function parseModule (module) {
              if (module.type !== "javascript") {
                throw new Error("Cannot parse non-JavaScript.  Please configure appropriate plugin.");
              }
            
            
            Severity: Minor
            Found in src/compile/modules/parse.js - About 1 hr to fix

              Function watch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Interlock.prototype.watch = function (cb, opts = {}) {
                const self = this;
                let lastCompilation = null;
                const absPathToModuleHash = Object.create(null);
              
              
              Severity: Minor
              Found in src/index.js - About 1 hr to fix

                Function validate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function validate (options, optionsDef) {
                  const cwd = process.cwd();
                
                  options = optionsDef.reduce((opts, option) => {
                    const hasKey = option.key in options;
                Severity: Minor
                Found in src/options/index.js - About 1 hr to fix

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

                  export default function resolve (requireStr, contextPath, ns, nsRoot, extensions, searchPaths = []) { // eslint-disable-line max-len,max-params
                    const resolvedSimple = resolveSimple(requireStr, contextPath, nsRoot, extensions);
                  
                    if (resolvedSimple) {
                      return {
                  Severity: Minor
                  Found in src/resolve.js - About 1 hr to fix

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

                    export default function () {
                      let topLevelNode;
                    
                      return {
                        visitor: {
                    Severity: Minor
                    Found in src/compile/modules/transform-amd.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 default has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function () {
                      let topLevelNode;
                    
                      return {
                        visitor: {
                    Severity: Minor
                    Found in src/compile/modules/transform-amd.js - About 1 hr to fix

                      Function watch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Interlock.prototype.watch = function (cb, opts = {}) {
                        const self = this;
                        let lastCompilation = null;
                        const absPathToModuleHash = Object.create(null);
                      
                      
                      Severity: Minor
                      Found in src/index.js - About 55 mins 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 enter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        enter (path, replacements) {
                          let { node } = path;
                      
                          if (node[TEMPLATE_SKIP]) { return path.skip(); }
                          if (t.isExpressionStatement(node)) { node = node.expression; }
                      Severity: Minor
                      Found in src/util/template.js - About 45 mins 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 resolve has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      export default function resolve (requireStr, contextPath, ns, nsRoot, extensions, searchPaths = []) { // eslint-disable-line max-len,max-params
                      Severity: Minor
                      Found in src/resolve.js - About 45 mins to fix

                        Function transformModule has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export default pluggable(function transformModule (module) {
                          if (module.type !== "javascript") {
                            throw new Error("Cannot transform non-JS module.  Please activate appropriate plugin.");
                          }
                          const babelUserConfig = this.opts.babelConfig || {};
                        Severity: Minor
                        Found in src/compile/modules/transform.js - About 45 mins 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 resolveDir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function resolveDir (absPath, extensions) {
                          if (!isDir(absPath)) { return null; }
                        
                          const packageJsonPath = path.join(absPath, "package.json");
                          if (isFile(packageJsonPath)) {
                        Severity: Minor
                        Found in src/resolve.js - About 45 mins 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 resolveModule has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function resolveModule (requireStr, contextPath, ns, nsRoot, extensions) {
                        Severity: Minor
                        Found in src/compile/modules/resolve.js - About 35 mins to fix

                          Function sendEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function sendEvent (connections, id, eventName, data, retryTimeout) {
                          Severity: Minor
                          Found in src/server/server.js - About 35 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return t.stringLiteral(val);
                            Severity: Major
                            Found in src/util/ast.js - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language