interlockjs/interlock

View on GitHub

Showing 34 of 34 total issues

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

}, {
  key: "split",
  schema: splitObj => {
    return isObject(splitObj) && Object.keys(splitObj).reduce((isValid, key) => {
      return isValid &&
Severity: Major
Found in src/options/compile.js and 1 other location - About 6 hrs to fix
src/options/compile.js on lines 53..73

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

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

}, {
  key: "entry",
  schema: entryObj => {
    return isObject(entryObj) && Object.keys(entryObj).reduce((isValid, key) => {
      return isValid &&
Severity: Major
Found in src/options/compile.js and 1 other location - About 6 hrs to fix
src/options/compile.js on lines 73..93

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

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

}, {
  key: "destRoot",
  default: cwd => path.join(cwd, "dist"),
  schema: isString,

Severity: Major
Found in src/options/compile.js and 1 other location - About 2 hrs to fix
src/options/compile.js on lines 25..39

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

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

export const compile = [{
  key: "srcRoot",
  default: cwd => path.join(cwd, "src"),
  schema: isString,

Severity: Major
Found in src/options/compile.js and 1 other location - About 2 hrs to fix
src/options/compile.js on lines 39..53

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

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

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

      export const server = [{
        key: "port",
        default: () => 1337,
        schema: portNum => isInteger(portNum) && portNum > 0,
      
      
      Severity: Major
      Found in src/options/server.js and 1 other location - About 1 hr to fix
      src/options/server.js on lines 25..37

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

      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

      }, {
        key: "retryTimeout",
        default: () => 3000,
        schema: timeout => isInteger(timeout) && timeout > 0,
      
      
      Severity: Major
      Found in src/options/server.js and 1 other location - About 1 hr to fix
      src/options/server.js on lines 13..25

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

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

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

                        map(this.opts.entry, (bundleDef, relPath) => this.initBundle(assign({}, bundleDef, {
                          module: modulesByPath[moduleSeeds[relPath].path],
                          isEntryPt: true
                        }))),
                    Severity: Major
                    Found in src/compile/bundles/get-seeds.js and 1 other location - About 1 hr to fix
                    src/compile/bundles/get-seeds.js on lines 26..29

                    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

                        map(this.opts.split, (bundleDef, relPath) => this.initBundle(assign({}, bundleDef, {
                          module: modulesByPath[moduleSeeds[relPath].path],
                          isEntryPt: false
                        })))
                    Severity: Major
                    Found in src/compile/bundles/get-seeds.js and 1 other location - About 1 hr to fix
                    src/compile/bundles/get-seeds.js on lines 22..25

                    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 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
                      Severity
                      Category
                      Status
                      Source
                      Language