witq/endoscope

View on GitHub

Showing 17 of 17 total issues

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

  it("should run all probles with level 0 when level 0 is specified", () => {
    const probe = () => Promise.resolve("ok");
    const cb = jest.fn().mockImplementation(arg => arg);

    endoscope.register(probe).register(probe, { level: 0 });
Severity: Major
Found in lib/endoscope.spec.js and 1 other location - About 4 hrs to fix
lib/endoscope.spec.js on lines 134..146

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

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

  it("should run all probles with level 1 and 0 when level 1 is specified", () => {
    const probe = () => Promise.resolve("ok");
    const cb = jest.fn().mockImplementation(arg => arg);

    endoscope.register(probe).register(probe, { level: 1 });
Severity: Major
Found in lib/endoscope.spec.js and 1 other location - About 4 hrs to fix
lib/endoscope.spec.js on lines 120..132

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

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

  it("should return probe message", () => {
    const probe = () => Promise.resolve("blblbl");

    return new Probe(probe, { timeout: 10 }).run().then(result => {
      expect(result).toEqual("blblbl");
Severity: Major
Found in lib/probe.spec.js and 1 other location - About 2 hrs to fix
lib/probe.spec.js on lines 82..88

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

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

  it("should return error message", () => {
    const probe = () => Promise.reject("err");

    return new Probe(probe, { timeout: 10 }).run().catch(error => {
      expect(error).toEqual("err");
Severity: Major
Found in lib/probe.spec.js and 1 other location - About 2 hrs to fix
lib/probe.spec.js on lines 66..72

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

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

    return handler(requestMock, responseMock).then(() => {
      expect(responseMock.writeHead.mock.calls).toMatchSnapshot();
      expect(responseMock.end.mock.calls).toMatchSnapshot();
    });
Severity: Major
Found in lib/middleware/http.spec.js and 4 other locations - About 1 hr to fix
lib/middleware/http.spec.js on lines 25..28
lib/middleware/http.spec.js on lines 38..41
lib/middleware/http.spec.js on lines 51..54
lib/middleware/http.spec.js on lines 64..67

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

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

    return handler(requestMock, responseMock).then(() => {
      expect(responseMock.writeHead.mock.calls).toMatchSnapshot();
      expect(responseMock.end.mock.calls).toMatchSnapshot();
    });
Severity: Major
Found in lib/middleware/http.spec.js and 4 other locations - About 1 hr to fix
lib/middleware/http.spec.js on lines 38..41
lib/middleware/http.spec.js on lines 51..54
lib/middleware/http.spec.js on lines 64..67
lib/middleware/http.spec.js on lines 82..85

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

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

    return handler(requestMock, responseMock).then(() => {
      expect(responseMock.writeHead.mock.calls).toMatchSnapshot();
      expect(responseMock.end.mock.calls).toMatchSnapshot();
    });
Severity: Major
Found in lib/middleware/http.spec.js and 4 other locations - About 1 hr to fix
lib/middleware/http.spec.js on lines 25..28
lib/middleware/http.spec.js on lines 38..41
lib/middleware/http.spec.js on lines 64..67
lib/middleware/http.spec.js on lines 82..85

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

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

    return handler(requestMock, responseMock).then(() => {
      expect(responseMock.writeHead.mock.calls).toMatchSnapshot();
      expect(responseMock.end.mock.calls).toMatchSnapshot();
    });
Severity: Major
Found in lib/middleware/http.spec.js and 4 other locations - About 1 hr to fix
lib/middleware/http.spec.js on lines 25..28
lib/middleware/http.spec.js on lines 51..54
lib/middleware/http.spec.js on lines 64..67
lib/middleware/http.spec.js on lines 82..85

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

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

    return handler(requestMock, responseMock).then(() => {
      expect(responseMock.writeHead.mock.calls).toMatchSnapshot();
      expect(responseMock.end.mock.calls).toMatchSnapshot();
    });
Severity: Major
Found in lib/middleware/http.spec.js and 4 other locations - About 1 hr to fix
lib/middleware/http.spec.js on lines 25..28
lib/middleware/http.spec.js on lines 38..41
lib/middleware/http.spec.js on lines 51..54
lib/middleware/http.spec.js on lines 82..85

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

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

    return endoscope
      .run()
      .catch(cb)
      .then(result => {
        expect(cb).toHaveBeenCalled();
Severity: Major
Found in lib/endoscope.spec.js and 1 other location - About 1 hr to fix
lib/endoscope.spec.js on lines 66..72

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

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

    return endoscope
      .run()
      .catch(cb)
      .then(result => {
        expect(cb).toHaveBeenCalled();
Severity: Major
Found in lib/endoscope.spec.js and 1 other location - About 1 hr to fix
lib/endoscope.spec.js on lines 30..36

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

module.exports = endoscopeInstance => (fastify, options, next) => {
  const endoscopeOptions = Object.assign(
    {},
    defaultEndoscopeOptions,
    options.endoscope
Severity: Minor
Found in lib/middleware/fastify.js - About 1 hr to fix

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

    module.exports = endoscopeInstance => (options = {}) => {
      const endoscopeOptions = Object.assign({}, defaultEndoscopeOptions, options);
    
      return (request, response) => {
        const url = parse(request.url);
    Severity: Minor
    Found in lib/middleware/http.js - About 1 hr to fix

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

          return handler({ params: {} }, resposeMock).then(() => {
            expect(resposeMock.status).toBeCalledWith(666);
          });
      Severity: Major
      Found in lib/middleware/express.spec.js and 3 other locations - About 35 mins to fix
      lib/middleware/express.spec.js on lines 47..49
      lib/middleware/fastify.spec.js on lines 62..64
      lib/middleware/fastify.spec.js on lines 90..92

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

      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

          return handler({ params: {} }, replyMock).then(() => {
            expect(replyMock.code).toBeCalledWith(200);
          });
      Severity: Major
      Found in lib/middleware/fastify.spec.js and 3 other locations - About 35 mins to fix
      lib/middleware/express.spec.js on lines 47..49
      lib/middleware/express.spec.js on lines 71..73
      lib/middleware/fastify.spec.js on lines 90..92

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

      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

          return handler({ params: {} }, replyMock).then(() => {
            expect(replyMock.code).toBeCalledWith(666);
          });
      Severity: Major
      Found in lib/middleware/fastify.spec.js and 3 other locations - About 35 mins to fix
      lib/middleware/express.spec.js on lines 47..49
      lib/middleware/express.spec.js on lines 71..73
      lib/middleware/fastify.spec.js on lines 62..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 47.

      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

          return handler({ params: {} }, resposeMock).then(() => {
            expect(resposeMock.status).toBeCalledWith(200);
          });
      Severity: Major
      Found in lib/middleware/express.spec.js and 3 other locations - About 35 mins to fix
      lib/middleware/express.spec.js on lines 71..73
      lib/middleware/fastify.spec.js on lines 62..64
      lib/middleware/fastify.spec.js on lines 90..92

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

      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