Function grib2json
has 55 lines of code (exceeds 25 allowed). Consider refactoring.
var grib2json = function (filePath, options) {
var numberFormatter = function (key, value) {
return value.toFixed ? Number(value.toFixed(options.precision)) : value
}
Function promise
has 49 lines of code (exceeds 25 allowed). Consider refactoring.
let promise = new Promise(function (resolve, reject) {
let optionsNames = Object.keys(options)
optionsNames = optionsNames.filter(arg => options[arg] &&
!INTERNAL_OPTIONS.includes(arg))
Method writeGridDefinition
has 32 lines of code (exceeds 25 allowed). Consider refactoring.
private void writeGridDefinition() {
final int gridTemplate = gds.getGdtn();
write("gridDefinitionTemplate", gridTemplate, codeTable3_1(gridTemplate));
write("numberPoints", gds.getNumberPoints());
Method main
has 30 lines of code (exceeds 25 allowed). Consider refactoring.
public static void main(String[] args) {
try {
Options options = CliFactory.parseArguments(Options.class, args);
if (options.getShowHelp() || options.getFile() == null) {
printUsage();
Similar blocks of code found in 2 locations. Consider refactoring.
private void writeRotationAndStretch() {
writeIfSet("spLon", gds.getSpLon());
writeIfSet("spLat", gds.getSpLat());
writeIfSet("rotationAngle", gds.getRotationAngle());
writeIfSet("poleLon", gds.getPoleLon());
src/main/java/net/nullschool/grib2json/GribRecordWriter.java on lines 131..138 Similar blocks of code found in 2 locations. Consider refactoring.
private void writeLonLatBounds() {
writeIfSet("lo1", gds.getLo1());
writeIfSet("la1", gds.getLa1());
writeIfSet("lo2", gds.getLo2());
writeIfSet("la2", gds.getLa2());
src/main/java/net/nullschool/grib2json/GribRecordWriter.java on lines 140..147 Method write
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
public void write() throws IOException {
RandomAccessFile raf = new RandomAccessFile(file.getPath(), "r");
raf.order(RandomAccessFile.BIG_ENDIAN);
Similar blocks of code found in 2 locations. Consider refactoring.
if (options.verbose) {
json.forEach(variable => console.log('Generated ' + variable.data.length + ' points in memory for variable ', variable.header))
}
Similar blocks of code found in 2 locations. Consider refactoring.
if (options.verbose) {
json.forEach(variable => console.log('Wrote ' + variable.data.length + ' points into file for variable ', variable.header))
}
Method main
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
public static void main(String[] args) {
try {
Options options = CliFactory.parseArguments(Options.class, args);
if (options.getShowHelp() || options.getFile() == null) {
printUsage();
Identical blocks of code found in 2 locations. Consider refactoring.
const grib2jsonCommand = process.env.GRIB2JSON ||
path.join(__dirname, 'bin', os.platform() === 'win32' ? 'grib2json.cmd' : 'grib2json')
Identical blocks of code found in 2 locations. Consider refactoring.
const grib2jsonCommand = process.env.GRIB2JSON ||
path.join(__dirname, 'bin', os.platform() === 'win32' ? 'grib2json.cmd' : 'grib2json')
Method isSelected
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
boolean isSelected() {
return
(options.getFilterDiscipline() == null || options.getFilterDiscipline() == ins.getDiscipline()) &&
(options.getFilterCategory() == null || options.getFilterCategory() == pds.getParameterCategory()) &&
(options.getFilterSurface() == null || options.getFilterSurface() == pds.getLevelType1()) &&
Method write
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
private void write(RandomAccessFile raf, Grib2Input input, Options options) throws IOException {
JsonGenerator jg = newJsonGenerator(options);
jg.writeStartArray();
List<Grib2Record> records = input.getRecords();