Skip to content

Commit 205c8cd

Browse files
author
Cameron Mace
committed
Merge modules into one sonarqube project
1 parent e2c67ff commit 205c8cd

15 files changed

Lines changed: 128 additions & 22 deletions

File tree

Makefile

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ checkstyle:
22
./gradlew checkstyle
33

44
sonarqube:
5-
./gradlew sonarqube \
6-
-DskipTests=true \
7-
-Dsonar.host.url=https://sonarcloud.io \
8-
-Dsonar.organization=mapbox \
9-
-Dsonar.login=$(SONARQUBE_API_TOKEN) \
10-
-Dsonar.test.failure.ignore=true
5+
./gradlew sonarqube
116

127
test:
138
./gradlew test
@@ -26,4 +21,80 @@ publish:
2621
export IS_LOCAL_DEVELOPMENT=false; ./gradlew :services-staticmap:uploadArchives ; \
2722
export IS_LOCAL_DEVELOPMENT=false; ./gradlew :services-turf:uploadArchives ; \
2823

29-
#TODO add get fixture commands
24+
publish-local:
25+
# This publishes to ~/.m2/repository/com/mapbox/mapboxsdk
26+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services:uploadArchives ; \
27+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-directions:uploadArchives ; \
28+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-geocoding:uploadArchives ; \
29+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-geojson:uploadArchives ; \
30+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-matching:uploadArchives ; \
31+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-matrix:uploadArchives ; \
32+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-optimization:uploadArchives ; \
33+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-staticmap:uploadArchives ; \
34+
export IS_LOCAL_DEVELOPMENT=true; ./gradlew :services-turf:uploadArchives ; \
35+
36+
directions-matrix-fixtures:
37+
# request a symmetric 3x3 matrix for cars
38+
curl "https://api.mapbox.com/directions-matrix/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73?access_token=$(MAPBOX_ACCESS_TOKEN)" \
39+
-o services-matrix/src/test/resources/directions_matrix_3x3.json
40+
41+
# request an asymmetric 2x3 matrix for bicycles
42+
curl "https://api.mapbox.com/directions-matrix/v1/mapbox/cycling/-122.42,37.78;-122.45,37.91;-122.48,37.73?sources=0;2&destinations=all&access_token=$(MAPBOX_ACCESS_TOKEN)" \
43+
-o services-matrix/src/test/resources/directions_matrix_2x3.json
44+
45+
geocoding-fixtures:
46+
# Geocoding: 1600 Pennsylvania Ave NW
47+
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/1600+pennsylvania+ave+nw.json?access_token=$(MAPBOX_ACCESS_TOKEN)" \
48+
-o services-geocoding/src/test/resources/geocoding.json
49+
50+
# Reverse geocoding: -77.0366, 38.8971
51+
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/-77.0366,38.8971.json?access_token=$(MAPBOX_ACCESS_TOKEN)" \
52+
-o services-geocoding/src/test/resources/geocoding_reverse.json
53+
54+
# Not supported country
55+
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/1600+pennsylvania+ave+nw.json?country=aq&access_token=$(MAPBOX_ACCESS_TOKEN)" \
56+
-o services-geocoding/src/test/resources/geocoding_country_not_supported.json
57+
58+
geocoding-batch-fixtures:
59+
curl "https://api.mapbox.com/geocoding/v5/mapbox.places-permanent/20001;20009;22209.json?access_token=$(MAPBOX_ACCESS_TOKEN)" \
60+
-o services-geocoding/src/test/resources/geocoding_batch.json
61+
62+
directions-fixtures:
63+
# Directions: polyline geometry with precision 5
64+
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
65+
-o services-directions/src/test/resources/directions_v5.json
66+
67+
# Directions: request annotations
68+
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&language=sv&steps=true&annotations=distance,duration,speed&access_token=$(MAPBOX_ACCESS_TOKEN)" \
69+
-o services-directions/src/test/resources/directions_annotations_v5.json
70+
71+
# Directions: polyline geometry with precision 6
72+
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline6&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
73+
-o services-directions/src/test/resources/directions_v5_precision_6.json
74+
75+
# Directions: route with a rotary
76+
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-77.04430818557739,38.908650612656864;-77.04192638397217,38.90963574367117?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
77+
-o services-directions/src/test/resources/directions_v5_fixtures_rotary.json
78+
79+
# Directions: route with traffic
80+
curl "https://api.mapbox.com/directions/v5/mapbox/driving-traffic/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
81+
-o services-directions/src/test/resources/directions_v5_traffic.json
82+
83+
# Directions: allow roundabout exits
84+
curl "https://api.mapbox.com/directions/v5/mapbox/driving-traffic/-77.04014240930304,38.91313201360546;-77.04573453985853,38.90725177816208.json?steps=true&overview=full&geometries=polyline&roundabout_exits=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
85+
-o services-directions/src/test/resources/directions_v5_roundabout_exits.json
86+
87+
mapmatching-fixtures:
88+
curl "https://api.mapbox.com/matching/v5/mapbox/driving/$(MAP_MATCHING_COORDINATES)?geometries=polyline&language=sv&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
89+
-o services-matching/src/test/resources/mapmatching_v5_polyline.json
90+
91+
optimization-fixtures:
92+
# request an optimized car trip with no additional options
93+
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73?access_token=$(MAPBOX_ACCESS_TOKEN)" \
94+
-o services-optimization/src/test/resources/optimized_trip.json
95+
96+
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/cycling/-122.42,37.78;-122.45,37.91;-122.48,37.73?steps=true&language=sv&access_token=$(MAPBOX_ACCESS_TOKEN)" \
97+
-o services-optimization/src/test/resources/optimized_trip_steps.json
98+
99+
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219;13.418555,52.523215?roundtrip=true&distributions=3,1&access_token=$(MAPBOX_ACCESS_TOKEN)" \
100+
-o services-optimization/src/test/resources/optimized_trip_distributions.json

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
<a href="https://circleci.com/gh/mapbox/mapbox-java">
1414
<img src="https://circleci.com/gh/mapbox/mapbox-java.svg?style=shield&circle-token=:circle-token">
1515
</a>
16-
<a href="https://www.codacy.com/app/Mapbox/mapbox-java?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=mapbox/mapbox-java&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/ca94241293664cdf86bd1848111955c5"/></a>
17-
16+
<a href="https://sonarcloud.io/dashboard?id=mapbox-java-services"><img src="https://sonarcloud.io/api/badges/gate?key=mapbox-java-services"/></a>
1817
</p>
1918
<br>
2019

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ subprojects {
5757
}
5858
}
5959

60+
apply from: "${rootDir}/gradle/sonarqube.gradle"
61+

docs/sonarqube.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Sonarqube
2+
3+
Starting with Mapbox Java 3.0 we use [SonarQube](https://www.sonarqube.org/) for tracking of static analysis issues, code coverage, project stat history, etc. This doc will walk through local setup and some of the features Sonarqube offers.
4+
5+
The project is public accessible through [SonarCloud](https://sonarcloud.io/dashboard?id=mapbox-java-services).
6+
7+
## Setup
8+
9+
### SonarCloud Account
10+
To get admin access on SonarCloud, [sign in](https://sonarcloud.io/sessions/new) using your Github account and ping in the `#android` slack channel that you'd like access to the Mapbox organization.
11+
12+
**Important:** Once signed in, you'll want to generate a security token and add it to your `bash_profile` so you can locally run the `sonarqube` gradle task. Once logged in, goto `My Account → Security`, enter a token name, and generate. Note that running the gradle command locally will update the project on SonarCloud using your current branch status, thus, it's best to let CI run all updates and only running locally if you have a valid reason.
13+
14+
### SonarLint
15+
Intellij has a plugin which helps quickly catch and resolve issues in real-time. To install, goto `Preferences → Plugins → Browse Repositories` and search SonarLint.
16+
17+
To follow the project rules in place, make sure to connect the plugin following the [official instructions](http://www.sonarlint.org/intellij/index.html#Connected).
18+
19+
20+
### Long-lived Non-branch analysis
21+
In the case you want to maintain analysis of the canonical project in SonarQube, say the "master" branch, and also publish in SonarQube ongoing analysis of a secondary branch. The typical case is a release branch. In this scenario, you add the sonar.branch=[branch key] analysis property to the release branch to create a second, independent project in SonarQube.
22+
23+
### Github PR Analysis
24+
TODO Needs to be setup once 3.0 is merged into master
25+
26+
## Features
27+
28+
### Issues
29+
The key feature of SonarQube is the issue tracker. The Mapbox organization contains a set of rules or "ways" which help eliminate common Java errors. These run each time the `sonarqube` gradle task is run and if new issues are found, a new issue in the queue will be open with detailed information on how to resolve
30+
31+
In some cases, these issues can be a false positive and can be resolved by using the `Open` dropdown menu and marking the issue appropriately and giving a reason.
32+
33+
### Method/Function tracking
34+
For Android users, method count is critical information to know and keep track of. SonarQube allows you to track this information over time under the `measures` tab in the project. Click on `Size → Functions` and you'll see a list of the project files and the number of methods in each file. Above the list, you'll find a graph icon which can show progress and changes over time.
35+
36+
By default, this shows the entire projects method count which is misleading since each module is published separately. To fix this and display individual module stats, locate the hamburger menu icon above the list of files and switch from `List` to `Tree`. This will list all the modules within the project and the method count.
37+
38+
**Note:** These number don't include dependency method count.

gradle/sonarqube.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ apply plugin: 'org.sonarqube'
33
sonarqube {
44
properties {
55
property "sonar.java.coveragePlugin", "jacoco"
6+
property "sonar.host.url", "https://sonarcloud.io"
7+
property "sonar.login", System.env.SONARQUBE_API_TOKEN
8+
property "sonar.organization", "mapbox"
9+
property "sonar.projectName", "mapbox-java"
10+
property "sonar.projectKey", "mapbox-java-services"
611
property "sonar.jacoco.reportPaths", "${project.buildDir}/jacoco/test.exec"
712
property "sonar.links.homepage", "https://github.com/mapbox/mapbox-java"
813
}

services-directions/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ dependencies {
2525
}
2626

2727
apply from: "${rootDir}/gradle/checkstyle.gradle"
28-
apply from: "${rootDir}/gradle/sonarqube.gradle"
2928
apply from: "${rootDir}/gradle/jacoco.gradle"
3029
apply from: "${rootDir}/gradle/mvn-push.gradle"

services-geocoding/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ dependencies {
2525
}
2626

2727
apply from: "${rootDir}/gradle/checkstyle.gradle"
28-
apply from: "${rootDir}/gradle/sonarqube.gradle"
2928
apply from: "${rootDir}/gradle/jacoco.gradle"
3029
apply from: "${rootDir}/gradle/mvn-push.gradle"

services-geojson/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ dependencies {
2020
}
2121

2222
apply from: "${rootDir}/gradle/checkstyle.gradle"
23-
apply from: "${rootDir}/gradle/sonarqube.gradle"
2423
apply from: "${rootDir}/gradle/jacoco.gradle"
2524
apply from: "${rootDir}/gradle/mvn-push.gradle"

services-matching/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ dependencies {
2525
}
2626

2727
apply from: "${rootDir}/gradle/checkstyle.gradle"
28-
apply from: "${rootDir}/gradle/sonarqube.gradle"
2928
apply from: "${rootDir}/gradle/jacoco.gradle"
3029
apply from: "${rootDir}/gradle/mvn-push.gradle"

services-matrix/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ dependencies {
2525
}
2626

2727
apply from: "${rootDir}/gradle/checkstyle.gradle"
28-
apply from: "${rootDir}/gradle/sonarqube.gradle"
2928
apply from: "${rootDir}/gradle/jacoco.gradle"
3029
apply from: "${rootDir}/gradle/mvn-push.gradle"

0 commit comments

Comments
 (0)