ManiaJS/ManiaJS

View on GitHub

Showing 66 of 66 total issues

Function loadPluginModels has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async loadPluginModels (plugin: any, id: string, sequelize: Sequelize) {
    if (plugin.directory) {
      var modelDirectory = path.normalize(plugin.directory + '/models/');
      var exists = await fs.exists(modelDirectory);
      if (! exists) {
Severity: Minor
Found in src/Plugin/PluginManager.ts - About 1 hr to fix

    Function set has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public async set(key: string, foreignKeyOrValue: number | any, value?: any) {
        var realValue: any;
        var realForeignKey: number = null;
    
        if (typeof foreignKeyOrValue === 'number') {
    Severity: Minor
    Found in src/Setting/SettingStore.ts - About 1 hr to fix

      Function boot has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public async boot() {
          let Map: Model<any,any> = this.app.models['Map'];
      
          // Get all maps on server, sync with database.
          let mapList: any[] = await this.app.serverFacade.client.gbx.query('GetMapList', [-1, 0]);
      Severity: Minor
      Found in src/Game/Maps.ts - About 1 hr to fix

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

          public once (action: string, callback: Function) {
            this.listeners.push({action: action, callback: callback});
        
            this.app.uiFacade.manager.once(action, callback);
          }
        Severity: Minor
        Found in src/UI/Interface.ts and 1 other location - About 55 mins to fix
        src/UI/Interface.ts on lines 185..189

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

        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

          public on (action: string, callback: Function) {
            this.listeners.push({action: action, callback: callback});
        
            this.app.uiFacade.manager.on(action, callback);
          }
        Severity: Minor
        Found in src/UI/Interface.ts and 1 other location - About 55 mins to fix
        src/UI/Interface.ts on lines 197..201

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

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

          public loadSet(name: string, script: boolean) {
            if (script && ! this.prepared)
              this.prepareScriptedCallbacks();
        
            switch(name) {
        Severity: Minor
        Found in src/Server/CallbackManager.ts - 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 boot has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          public async boot() {
            let Map: Model<any,any> = this.app.models['Map'];
        
            // Get all maps on server, sync with database.
            let mapList: any[] = await this.app.serverFacade.client.gbx.query('GetMapList', [-1, 0]);
        Severity: Minor
        Found in src/Game/Maps.ts - 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

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

          manager.register({
            callback: 'TrackMania.PlayerCheckpoint',
            event: 'trackmania.player.checkpoint',
            parameters: {
              playerId: 0,
        Severity: Minor
        Found in src/Server/callbacks/TrackManiaCallbacks.ts and 1 other location - About 55 mins to fix
        src/Server/callbacks/ShootManiaCallbacks.ts on lines 121..131

        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

          manager.register({
            callback: 'LibXmlRpc_OnArmorEmpty',
            event: 'script.shootmania.armorempty',
            parameters: {
              shooter: 0,
        Severity: Minor
        Found in src/Server/callbacks/ShootManiaCallbacks.ts and 1 other location - About 55 mins to fix
        src/Server/callbacks/TrackManiaCallbacks.ts on lines 15..25

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

              case 'lg':
                sizes.boxWidth = 200; sizes.boxHeight = 100;
                sizes.barLeft = -100; sizes.barTop = 40; break;
        Severity: Major
        Found in src/UI/GenericInterface.ts and 2 other locations - About 50 mins to fix
        src/UI/GenericInterface.ts on lines 143..145
        src/UI/GenericInterface.ts on lines 146..148

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

              case 'md':
                sizes.boxWidth = 150; sizes.boxHeight = 75;
                sizes.barLeft = -75 ; sizes.barTop = 27; break;
        Severity: Major
        Found in src/UI/GenericInterface.ts and 2 other locations - About 50 mins to fix
        src/UI/GenericInterface.ts on lines 143..145
        src/UI/GenericInterface.ts on lines 149..151

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

              case 'sm':
                sizes.boxWidth = 100; sizes.boxHeight = 50;
                sizes.barLeft = -50; sizes.barTop = 15; break;
        Severity: Major
        Found in src/UI/GenericInterface.ts and 2 other locations - About 50 mins to fix
        src/UI/GenericInterface.ts on lines 146..148
        src/UI/GenericInterface.ts on lines 149..151

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

          public async enable (pluginId: string, forceIncompatible?: boolean) {
            var plugin: any;
        
            if (forceIncompatible && this.incompatible[pluginId])
              plugin = this.incompatible[pluginId];
        Severity: Minor
        Found in src/Plugin/PluginManager.ts - 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

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

          public destroy (id, logins?, hide?) {
            logins = logins || false;
            hide = hide || false;
        
            let send = '<manialink id="' + id + '"></manialink>';
        Severity: Minor
        Found in src/UI/UIManager.ts - 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

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

          public async disable (pluginId: string, incompatible?: boolean) {
            incompatible = incompatible || false;
            let plugin: any = this.plugins[pluginId];
            if (! plugin) throw new Error('Plugin ID not found in current enabled plugins!');
        
        
        Severity: Minor
        Found in src/Plugin/PluginManager.ts - 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

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

          manager.register({
            callback: 'ManiaPlanet.BillUpdated',
            event: 'bill.update',
            parameters: {
              billId: 0,
        Severity: Minor
        Found in src/Server/callbacks/ManiaPlanetCallbacks.ts and 1 other location - About 35 mins to fix
        src/Server/callbacks/ShootManiaCallbacks.ts on lines 72..81

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

        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

          manager.register({
            callback: 'LibAFK_Properties',
            event: 'script.afk.properties',
            parameters: {
              idletimelimit: 0,
        Severity: Minor
        Found in src/Server/callbacks/ShootManiaCallbacks.ts and 1 other location - About 35 mins to fix
        src/Server/callbacks/ManiaPlanetCallbacks.ts on lines 192..201

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

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

          public countSpectators(): number {
            var num = 0;
            if (! this.list) return num;
        
            for (let login in this.list) {
        Severity: Minor
        Found in src/Game/Players.ts - About 35 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 countPlayers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          public countPlayers(): number {
            var num = 0;
            if (! this.list) return num;
        
            for (let login in this.list) {
        Severity: Minor
        Found in src/Game/Players.ts - About 35 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

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

              if (plugin.hasOwnProperty('game') && plugin.game.hasOwnProperty('modes') && plugin.game.modes.length > 0) {
                if (plugin.game.modes.indexOf(currentMode) === -1) {
                  // Stop!
                  await this.disable (pluginId, true);
                }
        Severity: Minor
        Found in src/Plugin/PluginManager.ts and 2 other locations - About 35 mins to fix
        src/Plugin/PluginManager.ts on lines 165..172
        src/Plugin/PluginManager.ts on lines 259..264

        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

        Severity
        Category
        Status
        Source
        Language