Lesterpig/openparty-mafia

View on GitHub

Showing 48 of 48 total issues

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

module.exports = function() {

  // Metadata

  this.name        = "Mafia";
Severity: Major
Found in definition.js - About 6 hrs to fix

    Function exports has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function() {
    
      // Metadata
    
      this.name        = "Mafia";
    Severity: Minor
    Found in definition.js - About 4 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 init has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      init: function(room) {
    
        var roles = {};
        var sum = 0;
        var playerShift = 0;
    Severity: Major
    Found in roles/index.js - About 3 hrs to fix

      Function init has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        init: function(room) {
      
          var roles = {};
          var sum = 0;
          var playerShift = 0;
      Severity: Minor
      Found in roles/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

      Function getVoteAction has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        getVoteAction: function(role, stage) {
      
          return {
            isAvailable: function(player) {
              return player.room.currentStage === stage && (!player.roles || !player.roles.dead);
      Severity: Minor
      Found in lib/votes.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

          room.gameplay.mute = function(player) {
            if (!player.roles.dead) {
              // Disable channels
              player.setChannel("village", {r: true, w: false});
              if (player.roles.mafia)
      Severity: Major
      Found in roles/index.js and 1 other location - About 3 hrs to fix
      roles/index.js on lines 123..130

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

      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

          room.gameplay.unmute = function(player) {
            if (!player.roles.dead) {
              // Enable channels
              player.setChannel("village", {r: true, w: true});
              if (player.roles.mafia)
      Severity: Major
      Found in roles/index.js and 1 other location - About 3 hrs to fix
      roles/index.js on lines 114..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 98.

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

      module.exports = function() {
      
        return {
      
          name: "Parieur",
      Severity: Major
      Found in roles/gambler.js - About 2 hrs to fix

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

        module.exports = function() {
        
          return {
            start: function(room, callback) {
        
        
        Severity: Major
        Found in stages/vote.js - About 2 hrs to fix

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

          module.exports = function() {
          
            return {
              start: function(room, callback) {
                // Reset pending death
          Severity: Major
          Found in stages/mafia.js - About 2 hrs to fix

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

            module.exports = function() {
            
              return {
            
                name: "Terroriste",
            Severity: Minor
            Found in roles/terrorist.js - About 1 hr to fix

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

              module.exports = function() {
              
                return {
              
                  name: "Conseiller",
              Severity: Minor
              Found in roles/councilman.js - About 1 hr to fix

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

                module.exports = function() {
                
                  return {
                
                    name: "Dentiste",
                Severity: Minor
                Found in roles/dentist.js - About 1 hr to fix

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

                    return {
                  
                      name: "Mafioso",
                      desc: "Vous devez assassiner tous les innocents villageois...",
                      side: "mafia",
                  Severity: Major
                  Found in roles/mafia.js and 1 other location - About 1 hr to fix
                  roles/godfather.js on lines 11..24

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

                  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

                    return {
                  
                      name: "Parrain",
                      desc: "Vous devez assassiner tous les innocents villageois, vous apparaissez comme un innocent aux yeux du Détective...",
                      side: "mafia",
                  Severity: Major
                  Found in roles/godfather.js and 1 other location - About 1 hr to fix
                  roles/mafia.js on lines 5..18

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

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

                  module.exports = function() {
                  
                    return {
                  
                      name: "Docteur",
                  Severity: Minor
                  Found in roles/doctor.js - About 1 hr to fix

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

                      init: function(gameplay) {
                    
                        gameplay.resetPlayerInfo = function() {
                          this.room.players.forEach(function(p) {
                            this.sendPlayerInfo(p);
                    Severity: Minor
                    Found in lib/playerInfo.js - About 1 hr to fix

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

                      module.exports = function() {
                      
                        return {
                      
                          name: "Conseiller",
                      Severity: Minor
                      Found in roles/councilman.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 getVoteAction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        getVoteAction: function(role, stage) {
                      
                          return {
                            isAvailable: function(player) {
                              return player.room.currentStage === stage && (!player.roles || !player.roles.dead);
                      Severity: Minor
                      Found in lib/votes.js - About 1 hr to fix

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

                        module.exports = function() {
                        
                          return {
                        
                            name: "Secouriste",
                        Severity: Minor
                        Found in roles/rescuer.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language