zalando/tailor

View on GitHub

Showing 31 of 31 total issues

Function processRequest has 158 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function processRequest(options, request, response) {
    this.emit('start', request);
    const parentSpanContext = tracer.extract(
        FORMAT_HTTP_HEADERS,
        request.headers
Severity: Major
Found in lib/request-handler.js - About 6 hrs to fix

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

            const tailor = new Tailor({
                templatesPath: __dirname + '/templates',
                pipeAttributes: attributes => {
                    const timingGroups = attributes['timing-group']
                        ? attributes['timing-group'].split(',')
    Severity: Major
    Found in examples/fragment-performance/test.js and 1 other location - About 4 hrs to fix
    examples/fragment-performance/index.js on lines 5..16

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

    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 tailor = new Tailor({
        templatesPath: __dirname + '/templates',
        pipeAttributes: attributes => {
            const timingGroups = attributes['timing-group']
                ? attributes['timing-group'].split(',')
    Severity: Major
    Found in examples/fragment-performance/index.js and 1 other location - About 4 hrs to fix
    examples/fragment-performance/test.js on lines 11..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 121.

    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

    http
        .createServer((req, res) => {
            if (req.url === '/favicon.ico') {
                res.writeHead(200, { 'Content-Type': 'image/x-icon' });
                return res.end('');
    Severity: Major
    Found in examples/basic-css-and-js/index.js and 1 other location - About 3 hrs to fix
    examples/custom-tags/index.js on lines 46..56

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

    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

    http
        .createServer((req, res) => {
            if (req.url === '/favicon.ico') {
                res.writeHead(200, { 'Content-Type': 'image/x-icon' });
                return res.end('');
    Severity: Major
    Found in examples/custom-tags/index.js and 1 other location - About 3 hrs to fix
    examples/basic-css-and-js/index.js on lines 10..20

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

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

    async function analyseHooks(mark, measure, entries) {
        /**
         * Performance Marks
         * 6 incluging start and end for fragments to capture the fragment timeline
         *  -> Header - 2
    Severity: Major
    Found in examples/fragment-performance/hooks.js - About 2 hrs to fix

      Function exports has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = (fragmentName, fragmentUrl, modules = 1, delay = false) => (
          request,
          response
      ) => {
          const pathname = url.parse(request.url).pathname;
      Severity: Major
      Found in examples/multiple-fragments-with-custom-amd/fragment.js - About 2 hrs to fix

        Function constructor has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor(options) {
                super();
                const {
                    amdLoaderUrl = AMD_LOADER_URL,
                    filterRequestHeaders = options.filterHeaders || filterReqHeadersFn,
        Severity: Major
        Found in index.js - About 2 hrs to fix

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

          const server = http.createServer((req, res) => {
              if (req.url === '/favicon.ico') {
                  res.writeHead(200, { 'Content-Type': 'image/x-icon' });
                  return res.end('');
              }
          Severity: Major
          Found in examples/multiple-fragments-with-custom-amd/index.js and 1 other location - About 2 hrs to fix
          examples/fragment-performance/index.js on lines 17..23

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

          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

          const server = http.createServer((req, res) => {
              if (req.url === '/favicon.ico') {
                  res.writeHead(200, { 'Content-Type': 'image/x-icon' });
                  return res.end('');
              }
          Severity: Major
          Found in examples/fragment-performance/index.js and 1 other location - About 2 hrs to fix
          examples/multiple-fragments-with-custom-amd/index.js on lines 17..23

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

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

              fetch(request, isFallback = false, parentSpan = null) {
                  if (!isFallback) {
                      this.emit('start');
                  }
                  const url = isFallback
          Severity: Major
          Found in lib/fragment.js - About 2 hrs to fix

            Function handlePrimaryFragment has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const handlePrimaryFragment = (fragment, resultStream) => {
                    if (!shouldWriteHead) {
                        return;
                    }
            
            
            Severity: Minor
            Found in lib/request-handler.js - About 1 hr to fix

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

                  onResponse(response, isFallback, span) {
                      const { statusCode, headers } = response;
              
                      // Extract the assets from fragment link headers.
                      const refs = parseLinkHeader(
              Severity: Minor
              Found in lib/fragment.js - About 1 hr to fix

                Function loadCSS has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function loadCSS(href) {
                        var ss = doc.createElement('link');
                        var ref;
                        var refs = (doc.body || doc.getElementsByTagName('head')[0]).childNodes;
                        ref = refs[refs.length - 1];
                Severity: Minor
                Found in src/pipe.js - About 1 hr to fix

                  Function processTemplate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function processTemplate(request, options, context) {
                      const {
                          maxAssetLinks,
                          asyncStream,
                          handleTag,
                  Severity: Minor
                  Found in lib/process-template.js - About 1 hr to fix

                    Function next has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        next() {
                            if (this.isBusy) {
                                return;
                            }
                            if (this.queue.length === 0) {
                    Severity: Minor
                    Found in lib/streams/stringifier-stream.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 processRequest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = function processRequest(options, request, response) {
                        this.emit('start', request);
                        const parentSpanContext = tracer.extract(
                            FORMAT_HTTP_HEADERS,
                            request.headers
                    Severity: Minor
                    Found in lib/request-handler.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 end has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function end(index, script, attributes) {
                            var placeholder = placeholders[index];
                            var start = starts[index];
                            var end = currentScript();
                            var node;
                    Severity: Minor
                    Found in src/pipe.js - About 1 hr to fix

                      Function _transform has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          _transform(chunk, encoding, done) {
                              if (chunk instanceof Buffer) {
                                  this.queue.push(chunk);
                              } else if (typeof this.fn !== 'function') {
                                  if (chunk.name) {
                      Severity: Minor
                      Found in lib/streams/stringifier-stream.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 insertStart has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          insertStart() {
                              const { async: isAsync, id } = this.attributes;
                              this.styleRefs.forEach(uri => {
                                  this.stream.write(
                                      isAsync
                      Severity: Minor
                      Found in lib/fragment.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language