weacast/weacast-grib2json

View on GitHub

Showing 14 of 14 total issues

Function grib2json has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var grib2json = function (filePath, options) {
  var numberFormatter = function (key, value) {
    return value.toFixed ? Number(value.toFixed(options.precision)) : value
  }

Severity: Major
Found in index.js - About 2 hrs to fix

    Function promise has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      let promise = new Promise(function (resolve, reject) {
        let optionsNames = Object.keys(options)
        optionsNames = optionsNames.filter(arg => options[arg] &&
          // These ones are used internally
          !INTERNAL_OPTIONS.includes(arg))
    Severity: Minor
    Found in index.js - About 1 hr to fix

      Method writeGridDefinition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void writeGridDefinition() {
              final int gridTemplate = gds.getGdtn();
      
              write("gridDefinitionTemplate", gridTemplate, codeTable3_1(gridTemplate));
              write("numberPoints", gds.getNumberPoints());
      Severity: Minor
      Found in src/main/java/net/nullschool/grib2json/GribRecordWriter.java - About 1 hr to fix

        Method main has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static void main(String[] args) {
                try {
                    Options options = CliFactory.parseArguments(Options.class, args);
                    if (options.getShowHelp() || options.getFile() == null) {
                        printUsage();
        Severity: Minor
        Found in src/main/java/net/nullschool/grib2json/Launcher.java - About 1 hr to fix

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

              private void writeRotationAndStretch() {
                  writeIfSet("spLon", gds.getSpLon());  // longitude of the southern pole of projection
                  writeIfSet("spLat", gds.getSpLat());  // latitude of the southern pole of projection
                  writeIfSet("rotationAngle", gds.getRotationAngle());
                  writeIfSet("poleLon", gds.getPoleLon());  // longitude of the pole stretching
          Severity: Minor
          Found in src/main/java/net/nullschool/grib2json/GribRecordWriter.java and 1 other location - About 55 mins to fix
          src/main/java/net/nullschool/grib2json/GribRecordWriter.java on lines 131..138

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

          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

              private void writeLonLatBounds() {
                  writeIfSet("lo1", gds.getLo1());  // longitude of first grid point
                  writeIfSet("la1", gds.getLa1());  // latitude of first grid point
                  writeIfSet("lo2", gds.getLo2());  // longitude of last grid point
                  writeIfSet("la2", gds.getLa2());  // latitude of last grid point
          Severity: Minor
          Found in src/main/java/net/nullschool/grib2json/GribRecordWriter.java and 1 other location - About 55 mins to fix
          src/main/java/net/nullschool/grib2json/GribRecordWriter.java on lines 140..147

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

          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

          Method write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public void write() throws IOException {
          
                  // Try opening the file as GRIB format.
                  RandomAccessFile raf = new RandomAccessFile(file.getPath(), "r");
                  raf.order(RandomAccessFile.BIG_ENDIAN);
          Severity: Minor
          Found in src/main/java/net/nullschool/grib2json/Grib2Json.java - 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

                  if (options.verbose) {
                    json.forEach(variable => console.log('Generated ' + variable.data.length + ' points in memory for variable ', variable.header))
                  }
          Severity: Minor
          Found in index.js and 1 other location - About 40 mins to fix
          index.js on lines 45..47

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

          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

                    if (options.verbose) {
                      json.forEach(variable => console.log('Wrote ' + variable.data.length + ' points into file for variable ', variable.header))
                    }
          Severity: Minor
          Found in index.js and 1 other location - About 40 mins to fix
          index.js on lines 62..64

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

          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

          Method main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static void main(String[] args) {
                  try {
                      Options options = CliFactory.parseArguments(Options.class, args);
                      if (options.getShowHelp() || options.getFile() == null) {
                          printUsage();
          Severity: Minor
          Found in src/main/java/net/nullschool/grib2json/Launcher.java - 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 2 locations. Consider refactoring.
          Open

          const grib2jsonCommand = process.env.GRIB2JSON ||
            path.join(__dirname, 'bin', os.platform() === 'win32' ? 'grib2json.cmd' : 'grib2json')
          Severity: Minor
          Found in index.js and 1 other location - About 30 mins to fix
          set_permission.js on lines 5..6

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

          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

          const grib2jsonCommand = process.env.GRIB2JSON ||
            path.join(__dirname, 'bin', os.platform() === 'win32' ? 'grib2json.cmd' : 'grib2json')
          Severity: Minor
          Found in set_permission.js and 1 other location - About 30 mins to fix
          index.js on lines 7..8

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

          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

          Method isSelected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              boolean isSelected() {
                  return
                      (options.getFilterDiscipline() == null || options.getFilterDiscipline() == ins.getDiscipline()) &&
                      (options.getFilterCategory() == null || options.getFilterCategory() == pds.getParameterCategory()) &&
                      (options.getFilterSurface() == null  || options.getFilterSurface() == pds.getLevelType1()) &&
          Severity: Minor
          Found in src/main/java/net/nullschool/grib2json/GribRecordWriter.java - About 25 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

          Method write has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private void write(RandomAccessFile raf, Grib2Input input, Options options) throws IOException {
                  JsonGenerator jg = newJsonGenerator(options);
                  jg.writeStartArray();
          
                  List<Grib2Record> records = input.getRecords();
          Severity: Minor
          Found in src/main/java/net/nullschool/grib2json/Grib2Json.java - About 25 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

          Severity
          Category
          Status
          Source
          Language