teambot-club/teambot

View on GitHub

Showing 24 of 24 total issues

Function teambot has 171 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var teambot = function() {
    var Botkit = require('botkit'),
        skillsLoader = require('bot/skills-loader'),
        settingsProvider = require('server/providers/settings-provider'),
        winston = require('winston'),
Severity: Major
Found in bot/index.js - About 6 hrs to fix

    Function DataProvider has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var DataProvider = function() {
    
        function init(_mongoUri) {
            if (!mongoUri) {
                mongoUri = _mongoUri;
    Severity: Major
    Found in server/providers/data-provider.js - About 4 hrs to fix

      Function SkillsLoader has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var SkillsLoader = function () {
          var npm = require('npm'),
              skillsProvider = require('server/providers/skills-provider'),
              fs = require('fs');
      
      
      Severity: Major
      Found in bot/skills-loader.js - About 3 hrs to fix

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

        exports.getTeamInfo = function(req, res) {
            teamsProvider.getTeamInfo(function(err, data) {
                if (err) {
                    res.status(500).send(err);
                    return;
        Severity: Major
        Found in server/services/teams.js and 1 other location - About 3 hrs to fix
        server/services/teams.js on lines 18..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 113.

        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

        exports.removeTeamInfo = function(req, res) {
            teamsProvider.removeTeamInfo(function(err, data) {
                if (err) {
                    res.status(500).send(err);
                    return;
        Severity: Major
        Found in server/services/teams.js and 1 other location - About 3 hrs to fix
        server/services/teams.js on lines 3..16

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

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

        var Middleware = function() {
        
            function isLocalUser(userId) {
                var _isLocalUser = false;
        
        
        Severity: Minor
        Found in bot/middleware.js - About 3 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 startSlackApp has 90 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function startSlackApp(clientId, clientSecret, redirectUri) {
        
                loadLocalUsers();
        
                if (!hasOauthServer) {
        Severity: Major
        Found in bot/index.js - About 3 hrs to fix

          Function teambot has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          var teambot = function() {
              var Botkit = require('botkit'),
                  skillsLoader = require('bot/skills-loader'),
                  settingsProvider = require('server/providers/settings-provider'),
                  winston = require('winston'),
          Severity: Minor
          Found in bot/index.js - About 3 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

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

          exports.getByScope = function(req, res) {
          
              settingsProvider.getByScope(req.params.scope, function(err, data) {
                  if (err) {
                      res.status(500).send(err);
          Severity: Major
          Found in server/services/settings.js and 1 other location - About 2 hrs to fix
          server/services/settings.js on lines 24..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 91.

          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

          exports.removeScope = function(req, res) {
          
              settingsProvider.removeScope(req.params.scope, function(err, data) {
                  if (err) {
                      res.status(500).send(err);
          Severity: Major
          Found in server/services/settings.js and 1 other location - About 2 hrs to fix
          server/services/settings.js on lines 3..12

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

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

          var SkillsLoader = function () {
              var npm = require('npm'),
                  skillsProvider = require('server/providers/skills-provider'),
                  fs = require('fs');
          
          
          Severity: Minor
          Found in bot/skills-loader.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

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

                      dataProvider.get({}, 'teams', function(err, data) {
                          if (err) {
                              callback(err);
                              return;
                          }
          Severity: Major
          Found in server/providers/teams-provider.js and 1 other location - About 1 hr to fix
          server/providers/settings-provider.js on lines 8..17

          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

                      dataProvider.get({ 'scope': scope }, 'settings', function(err, data) {
                          if (err) {
                              callback(err);
                              return;
                          }
          Severity: Major
          Found in server/providers/settings-provider.js and 1 other location - About 1 hr to fix
          server/providers/teams-provider.js on lines 6..15

          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

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

          var SkillsProvider = function () {
              function getSkills(callback) {
                  try {
                      dataProvider.get({}, skillsCollectionName, function (err, data) {
                          if (err) {
          Severity: Minor
          Found in server/providers/skills-provider.js - About 1 hr to fix

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

            var SettingsProvider = function() {
            
                function getByScope(scope, callback) {
                    try {
            
            
            Severity: Minor
            Found in server/providers/settings-provider.js - About 1 hr to fix

              Function Middleware has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var Middleware = function() {
              
                  function isLocalUser(userId) {
                      var _isLocalUser = false;
              
              
              Severity: Minor
              Found in bot/middleware.js - About 1 hr to fix

                Function start has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function start(callback, skill) {
                        _skill = skill;
                
                        process.on('uncaughtException', function(err) {
                            console.error(err, 'Uncaught Exception thrown');
                Severity: Minor
                Found in bot/index.js - About 1 hr to fix

                  Function DataProvider has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var DataProvider = function() {
                  
                      function init(_mongoUri) {
                          if (!mongoUri) {
                              mongoUri = _mongoUri;
                  Severity: Minor
                  Found in server/providers/data-provider.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 start has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.start = function (req, res) {
                  
                      try {
                  
                          if (req.body.clientId && req.body.clientSecret && req.body.redirectUri) {
                  Severity: Minor
                  Found in server/services/bot.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 TeamsProvider has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var TeamsProvider = function() {
                      function getTeamInfo(callback) {
                          try {
                              dataProvider.get({}, 'teams', function(err, data) {
                                  if (err) {
                  Severity: Minor
                  Found in server/providers/teams-provider.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

                  Severity
                  Category
                  Status
                  Source
                  Language