ChiefOfGxBxL/WC3MapTranslator

View on GitHub

Showing 25 of 39 total issues

Function warToJson has 224 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static warToJson(buffer: Buffer): JsonResult<Info> {
        const result: Info = {
            map: {
                name: '',
                author: '',
Severity: Major
Found in lib/translators/InfoTranslator.ts - About 1 day to fix

    File InfoTranslator.ts has 458 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { HexBuffer } from '../HexBuffer';
    import { W3Buffer } from '../W3Buffer';
    import { WarResult, JsonResult } from '../CommonInterfaces'
    
    interface Map {
    Severity: Minor
    Found in lib/translators/InfoTranslator.ts - About 7 hrs to fix

      Function jsonToWar has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          public static jsonToWar(infoJson: Info): WarResult {
              const outBufferToWar = new HexBuffer();
      
              outBufferToWar.addInt(31); // file version, 0x1F
              outBufferToWar.addInt(infoJson.saves || 0);
      Severity: Minor
      Found in lib/translators/InfoTranslator.ts - About 5 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 jsonToWar has 109 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static jsonToWar(infoJson: Info): WarResult {
              const outBufferToWar = new HexBuffer();
      
              outBufferToWar.addInt(31); // file version, 0x1F
              outBufferToWar.addInt(infoJson.saves || 0);
      Severity: Major
      Found in lib/translators/InfoTranslator.ts - About 4 hrs to fix

        Function warToJson has 100 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static warToJson(buffer: Buffer): JsonResult<Terrain> {
                // create buffer
                const result: Terrain = {
                    tileset: '',
                    customTileset: false,
        Severity: Major
        Found in lib/translators/TerrainTranslator.ts - About 4 hrs to fix

          Function warToJson has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              public static warToJson(type: string, buffer: Buffer): JsonResult<ObjectModificationTable> {
                  const result = { original: {}, custom: {} };
                  const outBufferToJSON = new W3Buffer(buffer);
          
                  const fileVersion = outBufferToJSON.readInt();
          Severity: Minor
          Found in lib/translators/ObjectsTranslator.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 warToJson has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static warToJson(buffer: Buffer): JsonResult<Unit[]> {
                  const result = [];
                  const outBufferToJSON = new W3Buffer(buffer);
          
                  const fileId = outBufferToJSON.readChars(4), // W3do for doodad file
          Severity: Major
          Found in lib/translators/UnitsTranslator.ts - About 3 hrs to fix

            Function warToJson has 75 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static warToJson(buffer: Buffer): JsonResult<Sound[]> {
                    const result = [];
                    const outBufferToJSON = new W3Buffer(buffer);
            
                    const fileVersion = outBufferToJSON.readInt(), // File version
            Severity: Major
            Found in lib/translators/SoundsTranslator.ts - About 3 hrs to fix

              Function jsonToWar has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static jsonToWar(terrainJson: Terrain): WarResult {
                      const outBufferToWar = new HexBuffer();
              
                      /*
                       * Header
              Severity: Major
              Found in lib/translators/TerrainTranslator.ts - About 2 hrs to fix

                Function jsonToWar has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static jsonToWar(type: string, json): WarResult {
                        const outBufferToWar = new HexBuffer();
                
                        /*
                         * Header
                Severity: Major
                Found in lib/translators/ObjectsTranslator.ts - About 2 hrs to fix

                  Function warToJson has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static warToJson(buffer: Buffer): JsonResult<Unit[]> {
                          const result = [];
                          const outBufferToJSON = new W3Buffer(buffer);
                  
                          const fileId = outBufferToJSON.readChars(4), // W3do for doodad file
                  Severity: Minor
                  Found in lib/translators/UnitsTranslator.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 jsonToWar has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static jsonToWar(unitsJson: Unit[]): WarResult {
                          const outBufferToWar = new HexBuffer();
                  
                          /*
                           * Header
                  Severity: Major
                  Found in lib/translators/UnitsTranslator.ts - About 2 hrs to fix

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

                        public static warToJson(buffer: Buffer): JsonResult<Doodad[]> {
                            const result = [];
                            const outBufferToJSON = new W3Buffer(buffer);
                    
                            const fileId = outBufferToJSON.readChars(4); // W3do for doodad file
                    Severity: Major
                    Found in lib/translators/DoodadsTranslator.ts - About 2 hrs to fix

                      Function warToJson has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static warToJson(buffer: Buffer): JsonResult<Info> {
                              const result: Info = {
                                  map: {
                                      name: '',
                                      author: '',
                      Severity: Minor
                      Found in lib/translators/InfoTranslator.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 warToJson has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static warToJson(type: string, buffer: Buffer): JsonResult<ObjectModificationTable> {
                              const result = { original: {}, custom: {} };
                              const outBufferToJSON = new W3Buffer(buffer);
                      
                              const fileVersion = outBufferToJSON.readInt();
                      Severity: Major
                      Found in lib/translators/ObjectsTranslator.ts - About 2 hrs to fix

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

                            public static jsonToWar(soundsJson: Sound[]): WarResult {
                                const outBufferToWar = new HexBuffer();
                        
                                /*
                                 * Header
                        Severity: Minor
                        Found in lib/translators/SoundsTranslator.ts - About 1 hr to fix

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

                                  const generateTableFromJson = (tableType: TableType, tableData) => { // create "original" or "custom" table
                                      Object.keys(tableData).forEach((defKey) => {
                                          const obj = tableData[defKey];
                          
                                          // Original and new object ids
                          Severity: Minor
                          Found in lib/translators/ObjectsTranslator.ts - About 1 hr to fix

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

                                    const readModificationTable = (isOriginalTable: boolean) => {
                                        const numTableModifications = outBufferToJSON.readInt();
                            
                                        for (let i = 0; i < numTableModifications; i++) {
                                            const objectDefinition = []; // object definition will store one or more modification objects
                            Severity: Minor
                            Found in lib/translators/ObjectsTranslator.ts - About 1 hr to fix

                              Function warToJson has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static warToJson(buffer: Buffer): JsonResult<Region[]> {
                                      const result = [];
                                      const outBufferToJSON = new W3Buffer(buffer);
                              
                                      const fileVersion = outBufferToJSON.readInt(), // File version
                              Severity: Minor
                              Found in lib/translators/RegionsTranslator.ts - About 1 hr to fix

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

                                    public static warToJson(buffer: Buffer): JsonResult<Camera[]> {
                                        const result = [];
                                        const outBufferToJSON = new W3Buffer(buffer);
                                
                                        const fileVersion = outBufferToJSON.readInt(), // File version
                                Severity: Minor
                                Found in lib/translators/CamerasTranslator.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language