omise/omise-node

View on GitHub

Showing 14 of 14 total issues

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

omise.tokens.create(cardDetails).then(function(token) {
  console.log(token);
  return omise.customers.create({
    'email':       'john.doe@example.com',
    'description': 'John Doe (id: 30)',
Severity: Major
Found in examples/as_promises.js and 1 other location - About 5 hrs to fix
examples/as_promises.js on lines 66..87

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

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

omise.tokens.create(cardDetails).then(function(token) {
  console.log(token);
  return omise.customers.create({
    'email':       'john.doe@example.com',
    'description': 'John Doe (id: 30)',
Severity: Major
Found in examples/as_promises.js and 1 other location - About 5 hrs to fix
examples/as_promises.js on lines 40..61

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

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

module.exports.resourceActions = function(name, actions, options) {
  const path = resourcePath(name);
  return _.pick({
    create: function(data, callback) {
      return api.post(_makeOptions(options, path(), data), callback);
Severity: Major
Found in lib/apiResources.js - About 4 hrs to fix

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

    module.exports.resourceActions = function(name, actions, options) {
      const path = resourcePath(name);
      return _.pick({
        create: function(data, callback) {
          return api.post(_makeOptions(options, path(), data), callback);
    Severity: Minor
    Found in lib/apiResources.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

        listCards: function(resourceId, data, callback) {
          if (typeof (data) === 'function') {
            callback = data; data = null;
          }
          return api.get(_nestedPathOptions(options, path(resourceId), 'cards',
    Severity: Major
    Found in lib/apiResources.js and 1 other location - About 1 hr to fix
    lib/apiResources.js on lines 115..121

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

    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

        capture: function(resourceId, data, callback) {
          if (typeof (data) === 'function') {
            callback = data; data = null;
          }
          return api.post(_nestedPathOptions(options, path(resourceId), 'capture',
    Severity: Major
    Found in lib/apiResources.js and 1 other location - About 1 hr to fix
    lib/apiResources.js on lines 132..138

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

    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

    omise.schedules.create(chargeEvery2Days, function(err, schedule) {
      if (err) {
        console.log('error', err);
        return;
      }
    Severity: Major
    Found in examples/charge_schedule.js and 1 other location - About 1 hr to fix
    examples/charge_schedule.js on lines 50..58

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

    omise.schedules.create(monthlyCharge, function(err, schedule) {
      if (err) {
        console.log('error', err);
        return;
      }
    Severity: Major
    Found in examples/charge_schedule.js and 1 other location - About 1 hr to fix
    examples/charge_schedule.js on lines 23..31

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

    function _responseHandler(req) {
      return new Promise(function(resolve, reject) {
        req.on('response', function(res) {
          let resp = '';
          res.setEncoding('utf8');
    Severity: Minor
    Found in lib/api.js - About 1 hr to fix

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

      function _nestedPathOptions(opts, pathObj, resource, id, data) {
      Severity: Minor
      Found in lib/apiResources.js - About 35 mins to fix

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

        const transfers = function(config) {
          return resource.resourceActions('transfers',
            ['create', 'retrieve', 'update', 'list', 'destroy', 'schedules'],
            {...config, key: config['secretKey']}
          );
        Severity: Minor
        Found in lib/resources/Transfer.js and 2 other locations - About 35 mins to fix
        lib/resources/Dispute.js on lines 5..11
        lib/resources/Recipient.js on lines 5..10

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

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

        const disputes = function(config) {
          return resource.resourceActions('disputes',
            ['list', 'retrieve', 'update',
              'listOpen', 'listPending', 'listClosed'],
            {...config, key: config['secretKey']}
        Severity: Minor
        Found in lib/resources/Dispute.js and 2 other locations - About 35 mins to fix
        lib/resources/Recipient.js on lines 5..10
        lib/resources/Transfer.js on lines 5..10

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

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

        const recipients = function(config) {
          return resource.resourceActions('recipients',
            ['list', 'create', 'update', 'retrieve', 'destroy', 'schedules'],
            {...config, key: config['secretKey']}
          );
        Severity: Minor
        Found in lib/resources/Recipient.js and 2 other locations - About 35 mins to fix
        lib/resources/Dispute.js on lines 5..11
        lib/resources/Transfer.js on lines 5..10

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

        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 log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        logger.log = function(level, message) {
          const levels = ['error', 'warn', 'info'];
          if (levels.indexOf(level) >= levels.indexOf(logger.debugLevel)) {
            if (typeof message !== 'string') {
              message = JSON.stringify(message);
        Severity: Minor
        Found in lib/logger.js - About 25 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

        Severity
        Category
        Status
        Source
        Language