AgentiaSystems/agentia-semaphore

View on GitHub

Showing 24 of 24 total issues

Function requestOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function requestOptions(action, params) {
  var url = null,
    query = {},
    options = { headers: { 'User-Agent': 'SemaphoreJS ' + this.version }, method: 'GET' };

Severity: Minor
Found in lib/requestOptions.js - About 1 hr to fix

    Function smsOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function smsOptions(instance, params, options) {
      var body = {}, number;
    
      if (!params) {
        instance.lastError = new Error('Mobile number and message are required');
    Severity: Minor
    Found in lib/requestOptions.js - About 1 hr to fix

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

          case 'api key': {
            // validate the "api key"
            if (utils.isValidApiKey(value)) {
              // set if valid
              this._options[key] = value;
      Severity: Major
      Found in lib/set.js and 1 other location - About 1 hr to fix
      lib/set.js on lines 35..46

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

      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

          case 'from': {
            // make sure the "from" value is a string
            if (_.isString(value)) {
              // set if it is
              this._options[key] = value;
      Severity: Major
      Found in lib/set.js and 1 other location - About 1 hr to fix
      lib/set.js on lines 22..33

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

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

      function set(key, value) {
        // if only key argument exist, the treat as a get()
        if (arguments.length === 1) {
          return this._options[key];
        }
      Severity: Minor
      Found in lib/set.js - About 1 hr to fix

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

          if (!_.isString(params.startsAt) || !validDate.test(params.startsAt)) {
            instance.lastError = new Error('"startsAt" must be a valid ISO date');
            return false;
          }
        Severity: Major
        Found in lib/requestOptions.js and 1 other location - About 1 hr to fix
        lib/requestOptions.js on lines 111..114

        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

          if (!_.isString(params.endsAt) || !validDate.test(params.endsAt)) {
            instance.lastError = new Error('"endsAt" must be a valid ISO date');
            return false;
          }
        Severity: Major
        Found in lib/requestOptions.js and 1 other location - About 1 hr to fix
        lib/requestOptions.js on lines 106..109

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

        function requestOptions(action, params) {
          var url = null,
            query = {},
            options = { headers: { 'User-Agent': 'SemaphoreJS ' + this.version }, method: 'GET' };
        
        
        Severity: Minor
        Found in lib/requestOptions.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 smsOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function smsOptions(instance, params, options) {
          var body = {}, number;
        
          if (!params) {
            instance.lastError = new Error('Mobile number and message are required');
        Severity: Minor
        Found in lib/requestOptions.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

        semaphore.sms('09995551212', 'Semaphore is great!', function(error, results) {
            if (error) {
                console.log(error);
            } else {
                console.log(results);
        Severity: Minor
        Found in examples/example-sms.js and 1 other location - About 55 mins to fix
        examples/example-period.js on lines 5..11

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

        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

        semaphore.period('2014-07-01T12:00+08:00', '2014-07-01T14:00+08:00', function(error, results) {
            if (error) {
                console.log(error);
            } else {
                console.log(results);
        Severity: Minor
        Found in examples/example-period.js and 1 other location - About 55 mins to fix
        examples/example-sms.js on lines 5..11

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

        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

        semaphore.messages(function(error, results) {
            if (error) {
                console.log(error);
            } else {
                console.log(results);
        Severity: Minor
        Found in examples/example-messages.js and 1 other location - About 50 mins to fix
        examples/example-account.js on lines 5..11

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

        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

        semaphore.account(function(error, results) {
            if (error) {
                console.log(error);
            } else {
                console.log(results);
        Severity: Minor
        Found in examples/example-account.js and 1 other location - About 50 mins to fix
        examples/example-messages.js on lines 5..11

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

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

        function set(key, value) {
          // if only key argument exist, the treat as a get()
          if (arguments.length === 1) {
            return this._options[key];
          }
        Severity: Minor
        Found in lib/set.js - About 45 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

        Avoid too many return statements within this function.
        Open

              return null;
        Severity: Major
        Found in lib/requestOptions.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return true;
          Severity: Major
          Found in lib/requestOptions.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return false;
            Severity: Major
            Found in lib/requestOptions.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                return value;
              Severity: Major
              Found in lib/set.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return true;
                Severity: Major
                Found in lib/requestOptions.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return null;
                  Severity: Major
                  Found in lib/requestOptions.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language