ManiaJS/ManiaJS

View on GitHub

Showing 66 of 66 total issues

Function script has 252 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function script (manager: CallbackManager) {
  // First register legacy calls.
  legacy(manager);

  manager.register({
Severity: Major
Found in src/Server/callbacks/ManiaPlanetCallbacks.ts - About 1 day to fix

    Function script has 232 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function script (manager: CallbackManager) {
      legacy(manager);
    
      manager.register({
        callback: 'LibXmlRpc_Rankings',
    Severity: Major
    Found in src/Server/callbacks/ShootManiaCallbacks.ts - About 1 day to fix

      Function legacy has 172 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function legacy (manager: CallbackManager) {
      
        /**
         * PLAYER EVENTS
         */
      Severity: Major
      Found in src/Server/callbacks/ManiaPlanetCallbacks.ts - About 6 hrs to fix

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

            this.ui.global({
              title: this.title,
              header: this.header,
              body: this.body.slice(this.range.start, this.range.stop),
        
        
        Severity: Major
        Found in src/UI/Generic/ListView.ts and 1 other location - About 6 hrs to fix
        src/UI/Generic/ListView.ts on lines 356..371

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

        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 this.ui.global({
              title: this.title,
              header: this.header,
              body: this.body.slice(this.range.start, this.range.stop),
        
        
        Severity: Major
        Found in src/UI/Generic/ListView.ts and 1 other location - About 6 hrs to fix
        src/UI/Generic/ListView.ts on lines 227..242

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

        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

        File ManiaPlanetCallbacks.ts has 429 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * ManiaPlanet Generic Callbacks
         *
         * Maps generic mp callbacks into events.
         */
        Severity: Minor
        Found in src/Server/callbacks/ManiaPlanetCallbacks.ts - About 6 hrs to fix

          Function script has 154 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function script (manager: CallbackManager) {
            legacy(manager);
          
            // Common Trackmania
          
          
          Severity: Major
          Found in src/Server/callbacks/TrackManiaCallbacks.ts - About 6 hrs to fix

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

              private handle (player, command, params, data) {
                if (player.level >= command.level) {
                  return this.events.emit(command.command, this.app.gameFacade.players.list[data.login], params, data);
                }
                this.app.server.send().chat('Error, you are not allowed to use this command!', {destination: data.login}).exec();
            Severity: Major
            Found in src/Server/CommandManager.ts and 1 other location - About 3 hrs to fix
            src/Server/CommandManager.ts on lines 111..116

            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

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

              private handleAdmin (player, command, params, data) {
                if (player.level >= command.level) {
                  return this.events.emit(command.command, this.app.gameFacade.players.list[data.login], params, data);
                }
                this.app.server.send().chat('Error, you are not allowed to use this command!', {destination: data.login}).exec();
            Severity: Major
            Found in src/Server/CommandManager.ts and 1 other location - About 3 hrs to fix
            src/Server/CommandManager.ts on lines 96..101

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

              public async loadPlugins() {
                // Register for Mode Changes and Script Changes
                this.app.server.on('mode.change', (transition) => { this.onGameChange('mode', transition); });
            
                this.app.log.debug('Loading plugins from configuration...');
            Severity: Minor
            Found in src/Plugin/PluginManager.ts - 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 parse has 89 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public parse () {
                this.width      = 210;
                this.totalWidth = 0;
            
                this.page    = 0; // Current Page NR.
            Severity: Major
            Found in src/UI/Generic/ListView.ts - About 3 hrs to fix

              Function loadPluginModels has a Cognitive Complexity of 21 (exceeds 5 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 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 sendInterface has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                public async sendInterface (ui: Interface, force: boolean, updateLogins: string[]) {
                  var data    = {}; // Holds all global data.
                  var players = []; // Holds login.
              
                  var send    = '';
              Severity: Minor
              Found in src/UI/UIManager.ts - 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

              File ListView.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * List View
               */
              
              import {EventEmitter} from 'events';
              Severity: Minor
              Found in src/UI/Generic/ListView.ts - About 2 hrs to fix

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

                      let info = {
                        login: data.Login,
                        nickName: data.NickName,
                        playerId: data.PlayerId,
                        teamId: data.TeamId,
                Severity: Major
                Found in src/Game/Players.ts and 1 other location - About 2 hrs to fix
                src/Server/callbacks/ManiaPlanetCallbacks.ts on lines 74..87

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

                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 {
                        login: info.Login,
                        nickName: info.NickName,
                        playerId: info.PlayerId,
                        teamId: info.TeamId,
                Severity: Major
                Found in src/Server/callbacks/ManiaPlanetCallbacks.ts and 1 other location - About 2 hrs to fix
                src/Game/Players.ts on lines 75..88

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

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

                  public async sendInterface (ui: Interface, force: boolean, updateLogins: string[]) {
                    var data    = {}; // Holds all global data.
                    var players = []; // Holds login.
                
                    var send    = '';
                Severity: Major
                Found in src/UI/UIManager.ts - About 2 hrs to fix

                  Function _createAlert has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _createAlert(type, title, message, players, size, buttonText, iconstyle, iconsubstyle) {
                      if (typeof players === 'string') {
                        players = [players];
                      }
                      buttonText.yes = buttonText.yes || 'Yes';
                  Severity: Major
                  Found in src/UI/GenericInterface.ts - About 2 hrs to fix

                    Function constructor has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      constructor (facade: Database.Facade) {
                        this.app = facade.app;
                        let config = facade.config.config.config.db;
                        this.sequelize = null;
                    
                    
                    Severity: Major
                    Found in src/Database/Client.ts - About 2 hrs to fix

                      Function connect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public async connect(login: string, nickname: string, info?: PlayerInfo | boolean | any,
                                             emit?: boolean): Promise<Player> {
                          info = info || {};
                          emit = emit || false;
                      
                      
                      Severity: Minor
                      Found in src/Game/Players.ts - 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