Please register with and subscribe to the Timetables API. This is described in detail in section 7.2.1 Prerequisites of the Architecture Document.
The build pipeline publishes the application to Docker Hub. Thus, you can pull an image and run it.
Then, in the following, replace <YOUR CLIENT ID>
and <YOUR API KEY>
with the values displayed in the section "Berechtigungsnachweise" for your application in DB API Marketplace / Applications.
Note: The API Key will not be revealed. Please save the key to a password safe when creating it (see 7.2.1 Prerequisites of the Architecture Document).
export API_KEY=<YOUR API KEY>
export CLIENT_ID=<YOUR CLIENT ID>
docker run -p 8080:8080 --env API_KEY=$API_KEY --env CLIENT_ID=$CLIENT_ID boos/train-delays
To simply run the application:
API_KEY="<YOUR API KEY>" CLIENT_ID="<YOUR CLIENT ID>" ./gradlew bootRun
If you want to rebuild and reload the application automatically when the source code changes, you will need two terminals.
In the first terminal, recompile the application continuously:
./gradlew build --continuous
In the second terminal, run the application with live reload:
API_KEY="<YOUR API KEY>" CLIENT_ID="<YOUR CLIENT ID>" ./gradlew bootRun
See: Stackoverflow: Spring Boot bootRun with continuous build
Open a web browser and navigate to http://localhost:8080
Fire an HTTP GET request to http://localhost:8080/nextdeparture
curl --include http://localhost:8080/nextdeparture
traindelays.http contains additional sample requests.
The Swagger UI contains online documentation and is available at http://localhost:8080/swagger-ui.html
The Open API specification is available as JSON document at http://localhost:8080/v3/api-docs
The YAML version of the Open API specification is available at http://localhost:8080/v3/api-docs.yaml
... check code metrics using metrix++
-
Configure the location of the cloned metrix++ scripts
export METRIXPP=/path/to/metrixplusplus
-
Collect metrics
python "$METRIXPP/metrix++.py" collect --std.code.complexity.cyclomatic --std.code.lines.code --std.code.todo.comments --std.code.maintindex.simple -- .
-
Get an overview
python "$METRIXPP/metrix++.py" view --db-file=./metrixpp.db
-
Apply thresholds
python "$METRIXPP/metrix++.py" limit --db-file=./metrixpp.db --max-limit=std.code.complexity:cyclomatic:5 --max-limit=std.code.lines:code:25:function --max-limit=std.code.todo:comments:0 --max-limit=std.code.mi:simple:1
At the time of writing, I want to stay below the following thresholds:
--max-limit=std.code.complexity:cyclomatic:5
--max-limit=std.code.lines:code:25:function
--max-limit=std.code.todo:comments:0
--max-limit=std.code.mi:simple:1
Finally, remove all code duplication. The next section describes how to detect code duplication.
To detect duplicates I use the CPD Copy Paste Detector tool from the PMD Source Code Analyzer Project.
If you have installed PMD by download & unzip, replace pmd
by ./run.sh
.
The homebrew pmd formula makes the pmd
command globally available.
pmd cpd --minimum-tokens 50 --files src