ahmadnassri/mockbin

View on GitHub

Showing 32 of 32 total issues

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

module.exports = (req, res, next) => {
    req.bodyChunks = [];

    req.on("data", (chunk) => {
        req.bodyChunks.push(chunk);
Severity: Major
Found in lib/middleware/body-parser.js - About 4 hrs to fix

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

    module.exports = (req, res, next) => {
        res.bodyXmlObj = {
            response: res.body,
        };
    
    
    Severity: Major
    Found in lib/middleware/negotiate-content.js - About 2 hrs to fix

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

      module.exports = (client) => (req, res, next) => {
          client.get(`bin:${req.params.uuid}`, (err, value) => {
              if (err) {
                  debug(err);
      
      
      Severity: Major
      Found in lib/routes/bins/sample.js - About 2 hrs to fix

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

        module.exports = function bins(dsnStr) {
            // parse redis dsn
            const dsn = new URL(dsnStr);
        
            // connect to redis
        Severity: Major
        Found in lib/routes/bins.js - About 2 hrs to fix

          Function processFormData has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const processFormData = (event) => {
                  const response = {
                      status: "",
                      statusText: "",
                      httpVersion: "HTTP/1.1",
          Severity: Major
          Found in src/static/bin/create.js - About 2 hrs to fix

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

                    if (data) {
                        $('input[name="response"]').val(JSON.stringify(data));
                        $("pre code").text(JSON.stringify(data, null, 2));
                        hljs.highlightBlock($("pre code")[0]);
                    }
            Severity: Major
            Found in src/static/bin/create.js and 1 other location - About 1 hr to fix
            src/static/bin/create.js on lines 100..105

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

            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

                        if (data) {
                            $('input[name="response"]').val(JSON.stringify(data));
            
                            $("pre code").text(JSON.stringify(data, null, 2));
                            hljs.highlightBlock($("pre code")[0]);
            Severity: Major
            Found in src/static/bin/create.js and 1 other location - About 1 hr to fix
            src/static/bin/create.js on lines 77..81

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

            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

                endpoints.forEach((endpoint) => {
                    // add route to middleware
                    defaults.splice(3, 1, endpoint.route);
            
                    // assign router to action at path
            Severity: Major
            Found in lib/index.js and 1 other location - About 1 hr to fix
            lib/routes/bins.js on lines 72..78

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

            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

                endpoints.forEach((endpoint) => {
                    // add route to middleware
                    defaults.splice(3, 1, endpoint.route);
            
                    // assign router to action at path
            Severity: Major
            Found in lib/routes/bins.js and 1 other location - About 1 hr to fix
            lib/index.js on lines 44..50

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

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

            module.exports = (client) => (req, res, next) => {
                const id = req.params.uuid;
                const path = req.params[0];
                const compoundId = id + path;
            
            
            Severity: Minor
            Found in lib/routes/bins/update.js - About 1 hr to fix

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

              module.exports = function router(options) {
                  const router = express.Router();
              
                  const defaults = [
                      mw.forwarded,
              Severity: Minor
              Found in lib/index.js - About 1 hr to fix

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

                module.exports = (client) => (req, res, next) => {
                    let mock = req.jsonBody;
                
                    // check for full HAR
                    if (req.jsonBody?.response) {
                Severity: Minor
                Found in lib/routes/bins/create.js - About 1 hr to fix

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

                  module.exports = (options, done) => {
                      if (!options) {
                          throw Error("missing options");
                      }
                  
                  
                  Severity: Minor
                  Found in src/index.js - About 1 hr to fix

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

                    module.exports = (client) => (req, res, next) => {
                        let mock = req.jsonBody;
                    
                        // check for full HAR
                        if (req.jsonBody?.response) {
                    Severity: Minor
                    Found in lib/routes/bins/create.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

                        set: function setCookie(req, res, next) {
                            res.cookie(req.params.name, req.params.value);
                    
                            res.body = req.params.value;
                    
                    
                    Severity: Major
                    Found in lib/routes/cookies.js and 1 other location - About 1 hr to fix
                    lib/routes/headers.js on lines 16..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 68.

                    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

                        set: function setHeader(req, res, next) {
                            res.set(req.params.name, req.params.value);
                    
                            res.body = req.params.value;
                    
                    
                    Severity: Major
                    Found in lib/routes/headers.js and 1 other location - About 1 hr to fix
                    lib/routes/cookies.js on lines 14..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 68.

                    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 4 locations. Consider refactoring.
                    Open

                        text: {
                            status: 200,
                            statusText: "OK",
                            httpVersion: "HTTP/1.1",
                            headers: [
                    Severity: Major
                    Found in src/static/bin/create.js and 3 other locations - About 1 hr to fix
                    src/static/bin/create.js on lines 21..36
                    src/static/bin/create.js on lines 38..53
                    src/static/bin/create.js on lines 55..70

                    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 4 locations. Consider refactoring.
                    Open

                        xml: {
                            status: 200,
                            statusText: "OK",
                            httpVersion: "HTTP/1.1",
                            headers: [
                    Severity: Major
                    Found in src/static/bin/create.js and 3 other locations - About 1 hr to fix
                    src/static/bin/create.js on lines 4..19
                    src/static/bin/create.js on lines 21..36
                    src/static/bin/create.js on lines 38..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 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 4 locations. Consider refactoring.
                    Open

                        json: {
                            status: 200,
                            statusText: "OK",
                            httpVersion: "HTTP/1.1",
                            headers: [
                    Severity: Major
                    Found in src/static/bin/create.js and 3 other locations - About 1 hr to fix
                    src/static/bin/create.js on lines 4..19
                    src/static/bin/create.js on lines 38..53
                    src/static/bin/create.js on lines 55..70

                    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 4 locations. Consider refactoring.
                    Open

                        jsonp: {
                            status: 200,
                            statusText: "OK",
                            httpVersion: "HTTP/1.1",
                            headers: [
                    Severity: Major
                    Found in src/static/bin/create.js and 3 other locations - About 1 hr to fix
                    src/static/bin/create.js on lines 4..19
                    src/static/bin/create.js on lines 21..36
                    src/static/bin/create.js on lines 55..70

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language