Skip to content

Commit

Permalink
Minor style enhancements (#62)
Browse files Browse the repository at this point in the history
* Complete .gitignore to ignore all the IntelliJ junk

* A cleaner use of the try-with-resources

* Use streams and lambdas instead of while loop
  • Loading branch information
jbujalance authored and mivek committed Feb 24, 2019
1 parent 388d2af commit 0ee554b
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 11 deletions.
172 changes: 171 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,171 @@
/target/

# Created by https://www.gitignore.io/api/maven,eclipse,intellij+all
# Edit at https://www.gitignore.io/?templates=maven,eclipse,intellij+all

### Eclipse ###

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

### Eclipse Patch ###
# Eclipse Core
.project

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Annotation Processing
.apt_generated

.sts4-cache/

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# End of https://www.gitignore.io/api/maven,eclipse,intellij+all
7 changes: 2 additions & 5 deletions src/main/java/io/github/mivek/facade/MetarFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Metar decode(final String pCode) throws ParseException {
}

@Override
public Metar retrieveFromAirport(final String pIcao) throws IOException, ParseException {
public Metar retrieveFromAirport(final String pIcao) throws ParseException, IOException {
if (pIcao.length() != AbstractWeatherCodeFacade.ICAO) {
throw new ParseException(ErrorCodes.ERROR_CODE_INVALID_ICAO); // $NON-NLS-1$
}
Expand All @@ -45,11 +45,8 @@ public Metar retrieveFromAirport(final String pIcao) throws IOException, ParseEx
URL url = new URL(website);
URLConnection urlCo = url.openConnection();
try (BufferedReader br = new BufferedReader(new InputStreamReader(urlCo.getInputStream()))) {
String line = (String) br.lines().toArray()[1];
br.close();
String line = br.lines().toArray(String[]::new)[1];
return getParser().parse(line);
} catch (Exception e) {
throw e;
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/io/github/mivek/facade/TAFFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,9 @@ public TAF retrieveFromAirport(final String pIcao) throws IOException, URISyntax
URL url = new URL(website);
try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
StringBuilder sb = new StringBuilder();
String inputLine;
// Throw the first line since it is not part of the TAF event.
br.readLine();
while ((inputLine = br.readLine()) != null) {
// Remove tabs and add line returns.
sb.append(inputLine.replaceAll("\\s{2,}", "")).append("\n");
}
br.lines().forEach(currentLine -> sb.append(currentLine.replaceAll("\\s{2,}", "")).append("\n"));
return getParser().parse(format(sb.toString()));
}
}
Expand Down

0 comments on commit 0ee554b

Please sign in to comment.