xBytez/slackbotapi

View on GitHub

Showing 9 of 14 total issues

Function getIM has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

slackAPI.prototype.getIM = function (term) {
    var im = null,
        self = this;
    for (var i in self.slackData.ims) {
        if (self.slackData.ims[i].user === term) {
Severity: Minor
Found in lib/index.js - About 2 hrs 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 connectSlack has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

slackAPI.prototype.connectSlack = function (wsurl, cb) {
    var self = this;
    self.ws = new webSocket(wsurl);
    self.ws.on('open', function () {
        self.out('transport', 'Connected as ' + self.slackData.self.name + ' [' + self.slackData.self.id + '].');
Severity: Major
Found in lib/index.js - About 2 hrs to fix

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

    function slackAPI(args, err_cb) {
        err_cb = err_cb || function () {};
        var self = this;
        var authtoken = args.token;
    
    
    Severity: Minor
    Found in lib/index.js - About 1 hr to fix

      Function sendPM has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      slackAPI.prototype.sendPM = function (userID, text) {
          var self = this;
          var channel = self.getIM(userID);
          if (channel !== null) {
              self.sendSock({
      Severity: Minor
      Found in lib/index.js - About 1 hr to fix

        Function getGroup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        slackAPI.prototype.getGroup = function (term) {
            var group = null,
                self = this;
            for (var i in self.slackData.groups) {
                if (self.slackData.groups[i].name === term) {
        Severity: Minor
        Found in lib/index.js - About 55 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

        Function getChannel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        slackAPI.prototype.getChannel = function (term) {
            var channel = null,
                self = this;
            for (var i in self.slackData.channels) {
                if (self.slackData.channels[i].name === term) {
        Severity: Minor
        Found in lib/index.js - About 55 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

        Function getUser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        slackAPI.prototype.getUser = function (term) {
            var user = null,
                self = this;
            for (var i in self.slackData.users) {
                if (self.slackData.users[i].name === term) {
        Severity: Minor
        Found in lib/index.js - About 55 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

        Function getUserByEmail has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        slackAPI.prototype.getUserByEmail = function (term) {
            var user = null,
                self = this;
            for (var i in self.slackData.users) {
                if (self.slackData.users[i].profile.email === term) {
        Severity: Minor
        Found in lib/index.js - About 55 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

        Function slackAPI has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function slackAPI(args, err_cb) {
            err_cb = err_cb || function () {};
            var self = this;
            var authtoken = args.token;
        
        
        Severity: Minor
        Found in lib/index.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

        Severity
        Category
        Status
        Source
        Language