Skip to content

Commit 9cc6c66

Browse files
authored
chore: added lint report (#1406)
* chore: added lint report * chore: change path * chore: updated CodeQL * chore: get rid of deprecation * chore: get rid of deprecation * chore: merging several reports * chore: removed some lint warnings * chore: headers
1 parent 9a41bde commit 9cc6c66

17 files changed

+155
-96
lines changed

.github/workflows/lint-report.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Lint and Upload SARIF
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
pull_request:
22+
branches:
23+
- main
24+
25+
jobs:
26+
lint:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v3
32+
33+
- name: Set up JDK 17
34+
uses: actions/setup-java@v3
35+
with:
36+
distribution: 'adopt'
37+
java-version: '17'
38+
39+
- name: Run Android Lint
40+
run: ./gradlew lint
41+
42+
- name: Merge SARIF files
43+
run: |
44+
jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' library/build/reports/lint-results-debug.sarif demo/build/reports/lint-results-debug.sarif > merged.sarif
45+
46+
- name: Upload SARIF file
47+
uses: github/codeql-action/upload-sarif@v3
48+
with:
49+
sarif_file: merged.sarif

demo/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ plugins {
2121
}
2222

2323
android {
24+
lintOptions {
25+
sarifOutput = file("$buildDir/reports/lint-results.sarif")
26+
}
2427

2528
defaultConfig {
2629
compileSdk 34

demo/src/main/java/com/google/maps/android/utils/demo/ClusteringViewModelDemoActivity.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.json.JSONException;
3030

3131
public class ClusteringViewModelDemoActivity extends BaseDemoActivity {
32-
private ClusterManager<MyItem> mClusterManager;
3332
private ClusteringViewModel mViewModel;
3433

3534
@Override
@@ -59,7 +58,7 @@ protected void startDemo(boolean isRestore) {
5958

6059
mViewModel.getAlgorithm().updateViewSize(widthDp, heightDp);
6160

62-
mClusterManager = new ClusterManager<>(this, getMap());
61+
ClusterManager<MyItem> mClusterManager = new ClusterManager<>(this, getMap());
6362
mClusterManager.setAlgorithm(mViewModel.getAlgorithm());
6463

6564
getMap().setOnCameraIdleListener(mClusterManager);

demo/src/main/java/com/google/maps/android/utils/demo/CustomAdvancedMarkerClusteringDemoActivity.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
package com.google.maps.android.utils.demo;
1818

19+
import java.util.Objects;
1920
import java.util.Random;
2021

22+
import android.annotation.SuppressLint;
2123
import android.graphics.Color;
2224
import android.util.Log;
2325
import android.view.View;
@@ -94,6 +96,7 @@ private PinConfig.Builder getPinConfig() {
9496
return pinConfigBuilder;
9597
}
9698

99+
@SuppressLint("SetTextI18n")
97100
private View addTextAsMarker(int size) {
98101
TextView textView = new TextView(getApplicationContext());
99102
textView.setText("I am a cluster of size " + size);
@@ -143,7 +146,7 @@ public boolean onClusterClick(Cluster<Person> cluster) {
143146
try {
144147
getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
145148
} catch (Exception e) {
146-
e.printStackTrace();
149+
Log.e("MapsDemo", Objects.requireNonNull(e.getMessage()));
147150
}
148151

149152
return true;

demo/src/main/java/com/google/maps/android/utils/demo/CustomMarkerClusteringDemoActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
*/
4949
public class CustomMarkerClusteringDemoActivity extends BaseDemoActivity implements ClusterManager.OnClusterClickListener<Person>, ClusterManager.OnClusterInfoWindowClickListener<Person>, ClusterManager.OnClusterItemClickListener<Person>, ClusterManager.OnClusterItemInfoWindowClickListener<Person> {
5050
private ClusterManager<Person> mClusterManager;
51-
private Random mRandom = new Random(1984);
51+
private final Random mRandom = new Random(1984);
5252

5353
/**
5454
* Draws profile photos inside markers (using IconGenerator).

demo/src/main/java/com/google/maps/android/utils/demo/DistanceDemoActivity.java

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.maps.android.utils.demo;
1818

19+
import android.annotation.SuppressLint;
1920
import android.widget.TextView;
2021
import android.widget.Toast;
2122

@@ -60,6 +61,7 @@ protected void startDemo(boolean isRestore) {
6061
showDistance();
6162
}
6263

64+
@SuppressLint("SetTextI18n")
6365
private void showDistance() {
6466
double distance = SphericalUtil.computeDistanceBetween(mMarkerA.getPosition(), mMarkerB.getPosition());
6567
mTextView.setText("The markers are " + formatNumber(distance) + " apart.");

demo/src/main/java/com/google/maps/android/utils/demo/StreetViewDemoActivity.kt

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.maps.android.utils.demo
1818

19+
import android.annotation.SuppressLint
1920
import android.app.Activity
2021
import android.os.Bundle
2122
import android.widget.TextView
@@ -29,6 +30,7 @@ import kotlinx.coroutines.launch
2930

3031
class StreetViewDemoActivity : Activity() {
3132

33+
@SuppressLint("SetTextI18n")
3234
@OptIn(DelicateCoroutinesApi::class)
3335
override fun onCreate(savedInstanceState: Bundle?) {
3436
super.onCreate(savedInstanceState)

demo/src/main/res/layout/distance_demo.xml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2020 Google Inc.
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
3+
Copyright 2024 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
1616
-->
1717

1818
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -25,7 +25,7 @@
2525
android:layout_height="wrap_content"
2626
android:id="@+id/textView"/>
2727

28-
<fragment android:id="@+id/map"
28+
<androidx.fragment.app.FragmentContainerView android:id="@+id/map"
2929
android:layout_width="match_parent"
3030
android:layout_height="match_parent"
3131
android:name="com.google.android.gms.maps.SupportMapFragment"/>

demo/src/main/res/layout/geojson_demo.xml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2020 Google Inc.
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
3+
Copyright 2024 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
1616
-->
1717

1818
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -21,7 +21,7 @@
2121
android:layout_width="match_parent"
2222
android:layout_height="match_parent">
2323

24-
<fragment
24+
<androidx.fragment.app.FragmentContainerView
2525
android:id="@+id/map"
2626
android:layout_width="match_parent"
2727
android:layout_height="0dp"

demo/src/main/res/layout/heatmaps_demo.xml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2020 Google Inc.
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
3+
Copyright 2024 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
1616
-->
1717

1818
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -54,7 +54,7 @@
5454
android:layout_width="fill_parent"
5555
android:layout_height="wrap_content" />
5656

57-
<fragment
57+
<androidx.fragment.app.FragmentContainerView
5858
android:id="@+id/map"
5959
android:layout_width="match_parent"
6060
android:layout_height="0dp"

demo/src/main/res/layout/kml_demo.xml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2020 Google Inc.
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
3+
Copyright 2024 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
1616
-->
1717

1818
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -23,7 +23,7 @@
2323
android:layout_width="match_parent"
2424
android:layout_height="match_parent">
2525

26-
<fragment
26+
<androidx.fragment.app.FragmentContainerView
2727
android:id="@+id/map"
2828
android:layout_width="match_parent"
2929
android:layout_height="0dp"

demo/src/main/res/layout/map.xml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright 2020 Google Inc.
4-
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ http://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
3+
Copyright 2024 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
1616
-->
1717

1818
<!-- Note that the item mapId is required for Advanced Markers to work -->
19-
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
19+
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
2020
xmlns:map="http://schemas.android.com/apk/res-auto"
2121
android:id="@+id/map"
2222
map:mapId="mapId"

0 commit comments

Comments
 (0)