Skip to content

Commit 2384f9f

Browse files
authored
chore(api): Apply lints (#812)
* Clean up pinpoint * Clean up pinpoint dart * Update iOS script * Update CI order * Add Dart lints to API * Apply Android/iOS lints to API * Rename uuid * Small changes * Fix scripts * Clean up * Fix unit tests * Continue impl * Fix android unit tests * Remove duplicate lint check * Fix analytics app * Adjust java options * Bump java RAM * Remove concurrency * Disable gradle daemon * Update gradle properties * Update gradle config * Revert "Update gradle config" This reverts commit a43ad29. * Revert gradle changes * Disable gradle daemon * Add kotlin style flags * Disable gradle daemon * Bump JVM memory * Change daemon setting * Adjust JVM memory * Lint debug only * Fix API tests * Bump deps and fix coverage script * Fix Gradle version * Revert unnecessary changes * Update melos postclean files * Enable fatal infos * Fix analyze scope * Fix postbootstrap * Fix missing sample app * Fix order in CI * Revert add sample app * Revert order change * Revert license date * Revert "Revert license date" This reverts commit 1b93b3f.
1 parent 8bb3b2f commit 2384f9f

File tree

95 files changed

+2075
-1783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2075
-1783
lines changed

build-support/dependencies.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
1+
$swift_version = "5.0"
2+
13
# Include common tooling
24
def include_build_tools!
35
# Pin to 0.44.17 until we resolve closing braces
46
pod 'SwiftFormat/CLI', '0.44.17'
57
pod 'SwiftLint'
68
end
9+
10+
$lint_script = <<-EOF
11+
CONFIG_FILE="${SRCROOT}/../../../../../.swiftformat"
12+
if [[ -e "${CONFIG_FILE}" ]]; then
13+
"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" --config "${CONFIG_FILE}" --swiftversion "#{$swift_version}" "${SRCROOT}/../.symlinks/plugins/${PRODUCT_NAME}/ios"
14+
fi
15+
EOF
16+
17+
$format_script = <<-EOF
18+
CONFIG_FILE="${SRCROOT}/../../../../../.swiftlint.yml"
19+
if [[ -e "${CONFIG_FILE}" ]]; then
20+
"${PODS_ROOT}/SwiftLint/swiftlint" --config "${CONFIG_FILE}" --path "${SRCROOT}/../.symlinks/plugins/${PRODUCT_NAME}/ios"
21+
fi
22+
EOF
23+
24+
$default_script_phases = [
25+
# Format build phase
26+
{
27+
:name => 'SwiftFormat',
28+
:script => $lint_script,
29+
:execution_position => :before_compile
30+
},
31+
32+
# Lint build phase
33+
{
34+
:name => 'SwiftLint',
35+
:script => $format_script,
36+
:execution_position => :before_compile
37+
},
38+
]

build-support/lint_android.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#!/bin/bash
22

3+
set -euo pipefail
4+
5+
# Script is run from example/ folder.
6+
# Pop up a dir to get the package we're testing.
7+
pushd ..
8+
project=$(basename $PWD)
9+
popd
10+
311
cd android
412

513
# Run in background to prevent Melos from hanging
6-
./gradlew lint --quiet --console plain &
14+
./gradlew :$project:lintDebug --no-rebuild --no-daemon --stacktrace &
15+
gradle_pid=$!
16+
17+
if ! wait $gradle_pid; then
18+
exit 1
19+
fi

build-support/lint_ios.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -e
4+
35
if [ -z "$AMPLIFY_FLUTTER_ROOT" ]; then
46
echo "Must set AMPLIFY_FLUTTER_ROOT" >&2
57
exit 1

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
6+
7+
# (nydillon) Must be <=6.1.1 until this issue is resolved: https://github.com/gradle/gradle/issues/14132
8+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

melos.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ scripts:
1010
flutter pub global activate tuneup
1111
1212
copy_dummy_config: >
13-
melos exec --scope="*example*" --fail-fast -- \
13+
melos exec --scope="*example*,sample_app" -- \
1414
cp -n "\$MELOS_ROOT_PATH"/.circleci/dummy_amplifyconfiguration.dart lib/amplifyconfiguration.dart | true
1515
1616
build:examples:ios: >
@@ -68,12 +68,13 @@ scripts:
6868
6969
analyze:
7070
run: melos exec -c 1 --fail-fast -- \
71-
flutter analyze --no-fatal-infos
71+
flutter analyze
7272
description: >
7373
Analyzes all packages and fails if there are any errors.
7474
select-package:
7575
scope:
7676
- amplify_analytics_*
77+
- amplify_api*
7778

7879
lint:ios:
7980
run: |
@@ -86,6 +87,7 @@ scripts:
8687
dir-exists: ios
8788
scope:
8889
- amplify_analytics_pinpoint_example
90+
- amplify_api_example
8991

9092
lint:android:
9193
run: |
@@ -96,17 +98,23 @@ scripts:
9698
select-package:
9799
scope:
98100
- amplify_analytics_pinpoint_example
101+
- amplify_api_example
99102

100103
lint:pub: >
101104
melos exec -c 5 --fail-fast --no-private --ignore="*example*" -- \
102105
flutter pub publish --dry-run
103106

104-
postbootstrap: >
105-
melos run copy_dummy_config
107+
packages:fix: |
108+
melos exec -- \
109+
flutter analyze --no-fatal-infos --no-fatal-warnings >/dev/null 2>&1
110+
111+
postbootstrap: |
112+
melos run copy_dummy_config && \
113+
melos run packages:fix
106114
107115
postclean: >
108116
melos exec -- \
109-
rm -rf ./build ./android/.gradle ./ios/.symlinks ./ios/Pods ./android/.idea ./.idea
117+
rm -rf ./build ./android/.gradle ./ios/.symlinks ./ios/Pods ./ios/Podfile.lock
110118
111119
dev_dependencies:
112120
pedantic: ^1.9.0

packages/amplify_analytics_pinpoint/android/build.gradle

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ android {
3939
}
4040
lintOptions {
4141
disable 'InvalidPackage'
42-
disable 'GradleDependency'
42+
informational 'GradleDependency'
4343

4444
abortOnError true
4545
warningsAsErrors true
46+
checkTestSources true
47+
xmlReport false
48+
htmlReport false
4649
}
4750
testOptions {
4851
unitTests {
@@ -66,9 +69,9 @@ dependencies {
6669
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6770
implementation 'com.amplifyframework:aws-analytics-pinpoint:1.24.1'
6871
implementation 'com.amplifyframework:aws-auth-cognito:1.24.1'
69-
testImplementation 'junit:junit:4.13'
70-
testImplementation 'org.mockito:mockito-core:3.1.0'
71-
testImplementation 'org.mockito:mockito-inline:3.1.0'
72-
testImplementation 'androidx.test:core:1.2.0'
72+
testImplementation 'junit:junit:4.13.2'
73+
testImplementation 'org.mockito:mockito-core:3.10.0'
74+
testImplementation 'org.mockito:mockito-inline:3.10.0'
75+
testImplementation 'androidx.test:core:1.4.0'
7376
testImplementation 'org.robolectric:robolectric:4.3.1'
7477
}

packages/amplify_analytics_pinpoint/android/coverage.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ project.afterEvaluate {
9797
def variantSourceSets = variant.sourceSets.java.srcDirs.collect { it.path }.flatten()
9898
sourceDirectories.setFrom(project.files(variantSourceSets))
9999

100-
def androidTestsData = fileTree(dir: "${buildDir}/outputs/code_coverage/${variantName}AndroidTest/connected/", includes: ["**/*.ec"])
101-
102-
executionData(files([
103-
"$project.buildDir/jacoco/${unitTestTask}.exec",
104-
androidTestsData
100+
executionData(fileTree(dir: "$buildDir", includes: [
101+
"jacoco/${unitTestTask}.exec",
102+
"outputs/code_coverage/${variantName}AndroidTest/connected/*coverage.ec"
105103
]))
106104
}
107105

packages/amplify_analytics_pinpoint/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
5+
6+
# (nydillon) Must be <=6.1.1 until this issue is resolved: https://github.com/gradle/gradle/issues/14132
7+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

packages/amplify_analytics_pinpoint/android/src/main/kotlin/com/amazonaws/amplify/amplify_analytics_pinpoint/AmplifyAnalyticsBuilder.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.amplifyframework.analytics.UserProfile
2323
class AmplifyAnalyticsBuilder {
2424
companion object Builder {
2525

26-
fun createAnalyticsProperties(propertiesMap: HashMap<String, Any>): AnalyticsProperties {
26+
fun createAnalyticsProperties(propertiesMap: Map<String, Any>): AnalyticsProperties {
2727

2828
val propertiesBuilder: AnalyticsProperties.Builder = AnalyticsProperties.builder()
2929

@@ -54,7 +54,7 @@ class AmplifyAnalyticsBuilder {
5454

5555
fun createAnalyticsEvent(
5656
name: String,
57-
propertiesMap: HashMap<String, Any>
57+
propertiesMap: Map<String, Any>
5858
): AnalyticsEvent {
5959

6060
val eventBuilder: AnalyticsEvent.Builder = AnalyticsEvent.builder()
@@ -85,7 +85,7 @@ class AmplifyAnalyticsBuilder {
8585
return eventBuilder.build()
8686
}
8787

88-
fun createUserProfile(userProfileMap: HashMap<String, *>): UserProfile {
88+
fun createUserProfile(userProfileMap: Map<String, Any>): UserProfile {
8989

9090
val userProfileBuilder = UserProfile.builder()
9191

@@ -118,7 +118,7 @@ class AmplifyAnalyticsBuilder {
118118
return userProfileBuilder.build()
119119
}
120120

121-
private fun createUserLocation(userLocationMap: HashMap<String, *>): UserProfile.Location {
121+
private fun createUserLocation(userLocationMap: Map<String, Any?>): UserProfile.Location {
122122

123123
val locationBuilder = UserProfile.Location.builder()
124124

packages/amplify_analytics_pinpoint/example/android/.idea/codeStyles/Project.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)