Skip to content

Commit

Permalink
Release/1.5 (#134)
Browse files Browse the repository at this point in the history
* update pom after release

* Update README.md

* fix before deploy script

* Clean/pom and package (#118)

* Add UTF-8 encoding

* Rename package

* fix readme

* added coverage

* Excluded openjdk job if branch is master (#119)

* Excluded openjdk job if branch is master

* test on develop branch

* use matrix for build config

* test on develop branch

* Set back develop branch

* Update issue templates

Updated templates

* Feature/spot bugs (#126)

* Include spotbugs to build

* Fix bugs + parse when retrieving TAF AMD

* Feature/rmk (#110)

* Handle parsing of AO1 and AO2 tokens

* Parse remark Wind peak

Added english and french translations

* Handle parsing of Windshift in remarks

* Handle decoding of tower visibility

* Parse surface visibility in remarks

* Fix visibility regex

* Handle decoding of variable prevailing visibility

* Handle decoding of sector visibility

* Handle visibility at second location

* Handle tornadic activity in remark

* fix typo

* Use replaceFirst instead of replaceAll

* Fix coverage

* Handle parse of precipitation in remarks

Updated pregMatch method.

* Added test and translation for thunderstorm beg end

* Handle thunderstorm location

* Handle parse of hail size in remark

* Parse snow pellet intensity in remark

* Parse virga in remarks

* Handle parse of ceiling height in remark

* Parse obscurations in remarks

* fix tests

* Parse Variable sky condition in remarks

* Parse ceiling at second location in remarks

* Clean traduction keys

* Use Message attribute instead of calling static

* Added logging on unknown token in remark

* Add missing translation keys

* Add RemarkParser to AbstractPArser

Fix test

* fix conflicts

* remove virga from remarkParser since it is single token

* Feature/rmk sea level pressure (#123)

* Handle parse of sea level pressure in remark

* Handle SLPNO token

* fix tests

* Feature/rmk pressure rinsing falling rapidly (#124)

* Handle parse of sea level pressure in remark

* Handle SLPNO token

* Handle parse of pressure rising and falling rapidly

* Feature/rmk snow increasing rapidly (#125)

* Handle parse of sea level pressure in remark

* Handle SLPNO token

* fix tests

* Handle parse of pressure rising and falling rapidly

* Handle parse of snow incresing rapidly in remarks

* deactivate checkstyle

* remove cases of parse method

* set back checkstyle

* Include sonarCloud in build (#131)

* Include sonarCloud in build

* Added scripts for install and deploy

* fix travis yml

* remove sonar from cache

* Added url for sonar

* install script

* Fix addons

* added branchname for sonar

* update script

* disable codeclimate checkstyle

* remove codeclimate

* Update script.sh

* Update script.sh

* Add toString method in package model.trend.validity (#129)

* Add to string method for entities in model (#130)

* Add to string method for entities in model

* Add tests on toString method

Signed-off-by: jk KPADEY <[email protected]>

* Fix codacy + test

Signed-off-by: jk KPADEY <[email protected]>

* Update readme (#132)

* Feature/to string metar (#133)

* updated script to add PR sonar

Signed-off-by: jk KPADEY <[email protected]>

* Added toString to
- metar class
- Abstract trends class

Fix toString in
- AbstractWeatherContainer

Added asserts on metar toString

Signed-off-by: jk KPADEY <[email protected]>

* fix review

Signed-off-by: jk KPADEY <[email protected]>
  • Loading branch information
mivek authored Apr 7, 2019
1 parent 36fc41d commit 697dfa9
Show file tree
Hide file tree
Showing 66 changed files with 1,327 additions and 166 deletions.
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ checks:

plugins:
checkstyle:
enabled: true
enabled: false
config:
file: "checkstyle.xml"
pmd:
enabled: true
sonar-java:
enabled: true
config:
sonar.java.source: 8
sonar.java.source: 8
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

Expand Down
46 changes: 24 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
language: java
env:
global:
- CC_TEST_REPORTER_ID=80f941339411bc7abca6636030897e70dad49f2693f1bcc14ab9fda1b86bf63d
jdk:
- oraclejdk8
- openjdk8

cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'
addons:
sonarcloud:
organization: "mivek-github"
token:
secure: $SONARCLOUD_TOKEN

jobs:
include:
- if: branch in (develop, master)
jdk: oraclejdk8
- if: branch = develop
jdk: openjdk8

before_install:
# Retrieve keys only if building branch is either develop or master and not a pull request
- if ([ "$TRAVIS_BRANCH" = "develop" ] || [ "$TRAVIS_BRANCH" = "master" ]) && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import; fi
- if ([ "$TRAVIS_BRANCH" = "develop" ] || [ "$TRAVIS_BRANCH" = "master" ]) && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust; fi
- bash scripts/before_install.sh

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
install:
- mvn compile test-compile

script:
# If the branch is either develop or master then the deploy goal is used otherwise the maven install is used
- if ([ "$TRAVIS_BRANCH" = "develop" ] || [ "$TRAVIS_BRANCH" = "master" ]) && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mvn clean deploy --settings .settings.xml -P release,ossrh ; else mvn clean install; fi

after_script:
# Upload code coverage to code climate - with workaround for jacoco
- cp target/site/jacoco/jacoco.xml src/main/java/jacoco.xml
- cd src/main/java/
- ../../../cc-test-reporter after-build -t jacoco --exit-code $TRAVIS_TEST_RESULT
- bash scripts/script.sh

before_deploy: bash before_deploy.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST $NAME $EMAIL
before_deploy: bash scripts/before_deploy.sh

deploy:
provider: releases
Expand All @@ -35,5 +38,4 @@ deploy:
skip_cleanup: true
draft: true
on:
tags: true
branch: master
branch: master
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Master:
[![Build Status](https://travis-ci.org/mivek/MetarParser.svg?branch=master)](https://travis-ci.org/mivek/MetarParser)
Develop:
[![Build Status](https://travis-ci.org/mivek/MetarParser.svg?branch=develop)](https://travis-ci.org/mivek/MetarParser)
[![Maintainability](https://api.codeclimate.com/v1/badges/bfd4e09cccf432218d40/maintainability)](https://codeclimate.com/github/mivek/MetarParser/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/bfd4e09cccf432218d40/test_coverage)](https://codeclimate.com/github/mivek/MetarParser/test_coverage)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=io.github.mivek%3AmetarParser&metric=alert_status)](https://sonarcloud.io/dashboard?id=io.github.mivek%3AmetarParser)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=io.github.mivek%3AmetarParser&metric=coverage)](https://sonarcloud.io/dashboard?id=io.github.mivek%3AmetarParser)
# MetarParser


Expand All @@ -23,14 +23,14 @@ The trends of the metar are not parsed.
2. [Retrieve a metar](https://github.com/mivek/MetarParser#retrieve-the-metar-of-an-airport)
3. [Parse a taf](https://github.com/mivek/MetarParser#parse-a-taf)
4. [Retrieve a taf](https://github.com/mivek/MetarParser#retrieve-a-taf)
4. [Internationalization](https://github.com/mivek/MetarParser#io.github.mivekinternationalization)
4. [Internationalization](https://github.com/mivek/MetarParser#internationalization)

## Adding the dependency
```xml
<dependency>
<groupId>io.github.mivek</groupId>
<artifactId>metarParser</artifactId>
<version>1.3</version>
<version>1.4</version>
</dependency>
```
Or check [here](https://search.maven.org/artifact/io.github.mivek/metarParser/1.3/jar) if you are not using maven.
Expand Down
17 changes: 0 additions & 17 deletions before_deploy.sh

This file was deleted.

16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.mivek</groupId>
<artifactId>metarParser</artifactId>
<version>1.4</version>
<version>1.5</version>
<name>metarParser</name>
<description>This project is a metar parser.
Use the MetarFacade and its method "parse()" to parse a metar string and retrieve a Metar Object.</description>
Expand Down Expand Up @@ -37,6 +37,7 @@ Use the MetarFacade and its method "parse()" to parse a metar string and retriev
<maven.source.plugin.version>3.0.0</maven.source.plugin.version>
<maven.javadoc.plugin.version>2.9.1</maven.javadoc.plugin.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<developers>
Expand Down Expand Up @@ -78,6 +79,19 @@ Use the MetarFacade and its method "parse()" to parse a metar string and retriev
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.11</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions scripts/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -ev

if [ $TRAVIS_BRANCH = "master" ] && [ $TRAVIS_PULL_REQUEST = "false" ]
then
git config --local user.name $NAME
git config --local user.email $EMAIL
version=$(grep -Po -m1 '<version>(.*)</version>' pom.xml | grep -Po '(\d\.\d)')
git tag $version
fi
5 changes: 5 additions & 0 deletions scripts/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ];then
echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import
echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust
fi

10 changes: 10 additions & 0 deletions scripts/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ];then
if [ "$TRAVIS_PULL_REQUEST" = "false" ];then
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent deploy sonar:sonar --settings .settings.xml -P release,ossrh
else
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
fi
else
mvn install
fi
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/CloudQuantity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* Enumeration for cloud quantity.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/CloudType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* Enumeration for cloud type. The first attribute is the code used in the
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/Descriptive.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* Enumeration for descriptive. The first attribute is the code used in the
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/Intensity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* Enumeration for indicator.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/Phenomenon.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* Enumeration for phenomenon.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/TimeIndicator.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* Enumeration for time indicator in metar trends.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/enums/WeatherChangeType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.enums;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* @author mivek
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/mivek/exception/ErrorCodes.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.mivek.exception;

import io.github.mivekinternationalization.Messages;
import io.github.mivek.internationalization.Messages;

/**
* @author mivek
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/github/mivek/facade/MetarFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;

import io.github.mivek.exception.ErrorCodes;
import io.github.mivek.exception.ParseException;
Expand Down Expand Up @@ -41,10 +42,10 @@ public Metar retrieveFromAirport(final String pIcao) throws ParseException, IOEx
throw new ParseException(ErrorCodes.ERROR_CODE_INVALID_ICAO); // $NON-NLS-1$
}
String website = NOAA_METAR_URL + pIcao.toUpperCase() // $NON-NLS-1$
+ ".TXT"; //$NON-NLS-1$
+ ".TXT"; //$NON-NLS-1$
URL url = new URL(website);
URLConnection urlCo = url.openConnection();
try (BufferedReader br = new BufferedReader(new InputStreamReader(urlCo.getInputStream()))) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(urlCo.getInputStream(), StandardCharsets.UTF_8))) {
String line = br.lines().toArray(String[]::new)[1];
return getParser().parse(line);
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/io/github/mivek/facade/TAFFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import io.github.mivek.exception.ErrorCodes;
import io.github.mivek.exception.ParseException;
Expand Down Expand Up @@ -44,7 +47,7 @@ public TAF retrieveFromAirport(final String pIcao) throws IOException, URISyntax
String website = NOAA_TAF_URL + pIcao.toUpperCase() // $NON-NLS-1$
+ ".TXT"; //$NON-NLS-1$
URL url = new URL(website);
try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
StringBuilder sb = new StringBuilder();
// Throw the first line since it is not part of the TAF event.
br.readLine();
Expand All @@ -64,6 +67,11 @@ protected String format(final String pCode) throws ParseException {
if (!TAFParser.TAF.equals(lines[0].trim())) {
return pCode;
}
if ("AMD TAF".equals(lines[1].trim())) {
List<String> list = new ArrayList<>(Arrays.asList(lines));
list.remove(1);
lines = list.toArray(new String[0]);
}
// Case of TAF AMD, the 2 first lines must be merged.
return Arrays.stream(lines).reduce((x, y) -> x + y + "\n").orElseThrow(() -> new ParseException(ErrorCodes.ERROR_CODE_INVALID_MESSAGE));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.mivekinternationalization;
package io.github.mivek.internationalization;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

Expand Down Expand Up @@ -45,4 +46,13 @@ public void setLocale(final Locale pLocale) {
public String getString(final String pString) {
return fResourceBundle.getString(pString);
}

/**
* @param pString the translation to get
* @param pArguments the arguments to fill
* @return the translation of pString with the arguments.
*/
public String getString(final String pString, final Object... pArguments) {
return MessageFormat.format(getString(pString), pArguments);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @author mivek
*
*/
package io.github.mivek.internationalization;
16 changes: 16 additions & 0 deletions src/main/java/io/github/mivek/model/AbstractWeatherCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.time.LocalTime;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
* @author mivek
* Parent class of {@link Metar} and {@link TAF}.
Expand Down Expand Up @@ -73,4 +75,18 @@ public String getMessage() {
public void setMessage(final String pMessage) {
fMessage = pMessage;
}

/**
* @return a description of the object.
*/
@Override
public String toString() {
return new ToStringBuilder(this).
append("day of the month", fDay).
append("time of report", fTime).
append("airport", fAirport).
appendSuper(super.toString()).
append("original message", fMessage).
toString();
}
}
Loading

0 comments on commit 697dfa9

Please sign in to comment.