weacast/weacast-grib2json

View on GitHub

Showing 8 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

          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

          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

          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