Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Lints #918

Merged
merged 38 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d47c95f
Reorg + integ tests
Sep 24, 2021
053428e
Clean up
Sep 24, 2021
6a652ee
Update tests; attempt Android
Sep 24, 2021
53c0378
Throw if Android
Sep 27, 2021
847b0f4
Lint amplify_flutter and amplify_core
Oct 27, 2021
536f232
Fix
Oct 27, 2021
eac58a8
Re-enable CI/CD lints
Sep 27, 2021
49d6109
Fix amplify_flutter tests
Sep 27, 2021
3e0aa13
Run Android lints
Sep 27, 2021
899c8e6
Fix formatting
Sep 27, 2021
a7c50f4
Keep trying Android reset
Sep 28, 2021
06246b1
Create amplify_test_flutter package
Oct 27, 2021
ccff951
Fix API auth for REST (#925)
dnys1 Oct 1, 2021
6749fbb
feat(datastore): Add ModelField ReadOnly support (#599)
fjnoyp Oct 11, 2021
d807487
chore: 0.2.5 release (#975)
Oct 27, 2021
207a739
feat(datastore): add observeQuery API (#892)
Oct 27, 2021
128f035
Revert "feat(datastore): Add ModelField ReadOnly support (#599)" (#994)
Oct 27, 2021
17454f4
chore: 0.2.6 release (#993)
Oct 27, 2021
8846418
Fix imports
Oct 27, 2021
dac3a5c
Fix linting
Oct 27, 2021
a9b77d7
Update dependencies
Oct 27, 2021
ddc7a21
Add missing build tools
Oct 27, 2021
14409a9
Update pubspecs
Oct 27, 2021
140e1e3
Revert Android changes
Oct 27, 2021
05e1629
Use local dependencies
Oct 27, 2021
295ecf4
Update license and readme
Oct 27, 2021
57d3493
Trigger CI
Oct 27, 2021
39ae1eb
Fix imports
Oct 27, 2021
38ee1c8
Fix lints
Oct 27, 2021
121b58e
Revert amplify_flutter change
Oct 27, 2021
62a3860
Remove unnecessary lint disable
Oct 28, 2021
fb983dc
Revert DataStore model changes; fix yellow
Oct 28, 2021
e4cd233
Revert test pkg & integ tests
Oct 28, 2021
87f0748
Fix amplify_flutter example
Oct 28, 2021
4c2975b
Fix amplify_flutter example
Oct 28, 2021
9a1bb39
Fix amplify_flutter example
Oct 28, 2021
b18f154
Remove uuid from API plugin deps
Oct 28, 2021
cc49f79
Misc corrections
Oct 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build-support/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ def include_build_tools!
:execution_position => :before_compile
},
]

def get_plugin_dir(plugin_name)
return File.join('.symlinks', 'plugins', plugin_name, 'ios')
end
18 changes: 18 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ scripts:
scope:
- amplify_analytics_*
- amplify_api*
- amplify_flutter*
- amplify_core*

lint:ios:
run: |
Expand All @@ -111,6 +113,8 @@ scripts:
scope:
- amplify_analytics_pinpoint_example
- amplify_api_example
- amplify_flutter_example
- amplify_core_example

lint:android:
run: |
Expand All @@ -122,6 +126,20 @@ scripts:
scope:
- amplify_analytics_pinpoint_example
- amplify_api_example
- amplify_flutter_example
- amplify_core_example

copy_dependencies:
run: |
melos exec -c 1 -- \
cp "\$MELOS_ROOT_PATH"/build-support/dependencies.rb ios
description: Updates the iOS build dependencies for each project
select-package:
scope:
- amplify_analytics_pinpoint
- amplify_api
- amplify_flutter
- amplify_core

lint:pub: >
melos exec -c 5 --fail-fast --no-private --ignore="*example*" -- \
Expand Down
5 changes: 2 additions & 3 deletions packages/amplify_analytics_pinpoint/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load '../../../../build-support/dependencies.rb'
load '../../ios/dependencies.rb'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for copying + reading copies rather than reading centralized version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not much of a reason in the examples, since they will only ever be run from the repo. But in general, it must be copied to each package because they are shipped independently in pub. This issue is why we had to do the 0.2.4 release 😅 because it was throwing errors that the file wasn't there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks for explanation


# Uncomment this line to define a global platform for your project
platform :ios, '13.0'
Expand Down Expand Up @@ -28,19 +28,18 @@ end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup
include_build_tools!

target 'Runner' do
use_frameworks!
use_modular_headers!
include_build_tools!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

target 'unit_tests' do
use_frameworks!
use_modular_headers!
include_build_tools!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Expand Down
5 changes: 2 additions & 3 deletions packages/amplify_analytics_pinpoint/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:flutter/material.dart';

import 'package:amplify_flutter/amplify.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public enum FlutterAnalytics {
bridge: AnalyticsBridge
) {
guard let argumentsMap = arguments as? [String: Any],
let name = argumentsMap["name"] as? String else {
let name = argumentsMap["name"] as? String
else {
result(invalidArgumentsError)
return
}
Expand Down Expand Up @@ -132,7 +133,8 @@ public enum FlutterAnalytics {
public static func identifyUser(arguments: Any?, result: @escaping FlutterResult, bridge: AnalyticsBridge) {
guard let arguments = arguments as? [String: Any],
let userId = arguments["userId"] as? String,
let userProfileMap = arguments["userProfileMap"] as? [String: Any] else {
let userProfileMap = arguments["userProfileMap"] as? [String: Any]
else {
result(invalidArgumentsError)
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load 'dependencies.rb'

#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint amplify_analytics_pinpoint.podspec' to validate before publishing.
Expand All @@ -18,9 +20,12 @@ This code is the iOS part of the Amplify Flutter Pinpoint Analytics Plugin. The
s.dependency 'Amplify', '~> 1.15.3'
s.dependency 'AmplifyPlugins/AWSPinpointAnalyticsPlugin', '~> 1.15.3'
s.dependency 'amplify_core'
s.dependency 'SwiftLint'
s.dependency 'SwiftFormat/CLI'
s.platform = :ios, '11.0'

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.swift_version = '5.0'
s.swift_version = $swift_version
s.script_phases = $default_script_phases
end
42 changes: 42 additions & 0 deletions packages/amplify_analytics_pinpoint/ios/dependencies.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$swift_version = "5.0"

# Include common tooling
def include_build_tools!
# Pin to 0.44.17 until we resolve closing braces
pod 'SwiftFormat/CLI', '0.44.17'
pod 'SwiftLint'
end

$lint_script = <<-EOF
CONFIG_FILE="${SRCROOT}/../../../../../.swiftformat"
if [[ -e "${CONFIG_FILE}" ]]; then
"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" --config "${CONFIG_FILE}" --swiftversion "#{$swift_version}" "${SRCROOT}/../.symlinks/plugins/${PRODUCT_NAME}/ios"
fi
EOF

$format_script = <<-EOF
CONFIG_FILE="${SRCROOT}/../../../../../.swiftlint.yml"
if [[ -e "${CONFIG_FILE}" ]]; then
"${PODS_ROOT}/SwiftLint/swiftlint" --config "${CONFIG_FILE}" --path "${SRCROOT}/../.symlinks/plugins/${PRODUCT_NAME}/ios"
fi
EOF

$default_script_phases = [
# Format build phase
{
:name => 'SwiftFormat',
:script => $lint_script,
:execution_position => :before_compile
},

# Lint build phase
{
:name => 'SwiftLint',
:script => $format_script,
:execution_position => :before_compile
},
]

def get_plugin_dir(plugin_name)
return File.join('.symlinks', 'plugins', plugin_name, 'ios')
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ library amplify_analytics_pinpoint;
import 'package:amplify_analytics_plugin_interface/amplify_analytics_plugin_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import './method_channel_amplify.dart';
import 'src/method_channel_amplify.dart';

export 'package:amplify_analytics_plugin_interface/src/types.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
*/

import 'package:amplify_analytics_plugin_interface/amplify_analytics_plugin_interface.dart';
import 'package:amplify_core/types/exception/AmplifyException.dart';
import 'package:amplify_core/types/exception/AmplifyAlreadyConfiguredException.dart';
import 'package:amplify_core/types/index.dart';
import 'package:amplify_core/amplify_core.dart';
import 'package:flutter/services.dart';

import 'amplify_analytics_pinpoint.dart';
import '../amplify_analytics_pinpoint.dart';

const MethodChannel _channel =
MethodChannel('com.amazonaws.amplify/analytics_pinpoint');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* permissions and limitations under the License.
*/

import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_analytics_plugin_interface/amplify_analytics_plugin_interface.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_analytics_plugin_interface/amplify_analytics_plugin_interface.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';

void main() {
const MethodChannel analyticsChannel =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ library amplify_analytics_plugin_interface;

import 'dart:async';

import 'package:amplify_core/types/index.dart';
import 'package:amplify_core/amplify_core.dart';
import 'package:meta/meta.dart';

import 'src/types.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

import 'package:amplify_core/types/exception/AmplifyException.dart';
import 'package:amplify_core/amplify_core.dart';

/// Base Class for Analytics Exceptions
class AnalyticsException extends AmplifyException {
Expand Down
6 changes: 3 additions & 3 deletions packages/amplify_api/example/integration_test/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* permissions and limitations under the License.
*/

import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:amplify_flutter/amplify.dart';
import 'package:amplify_api/amplify_api.dart';
import 'package:amplify_api_example/amplifyconfiguration.dart';
import 'package:amplify_flutter/amplify.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'graph_ql_tests.dart' as graph_ql_tests;

Expand Down
5 changes: 2 additions & 3 deletions packages/amplify_api/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load '../../../../build-support/dependencies.rb'
load '../../ios/dependencies.rb'

# Uncomment this line to define a global platform for your project
platform :ios, '13.0'
Expand Down Expand Up @@ -28,19 +28,18 @@ end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup
include_build_tools!

target 'Runner' do
use_frameworks!
use_modular_headers!
include_build_tools!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

target 'unit_tests' do
use_frameworks!
use_modular_headers!
include_build_tools!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify_api/example/lib/graphql_api_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* permissions and limitations under the License.
*/

import 'package:amplify_api/amplify_api.dart';
import 'package:amplify_flutter/amplify.dart';
import 'package:flutter/material.dart';
import 'package:amplify_api/amplify_api.dart';

class GraphQLApiView extends StatefulWidget {
final bool isAmplifyConfigured;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension FlutterError: Error {}
/// A factory of [FlutterAuthProvider] instances. Manages shared state for all providers.
class FlutterAuthProviders: APIAuthProviderFactory {
/// Thread to perform wait activities on.
static private let queue = DispatchQueue(label: "FlutterAuthProviders")
ragingsquirrel3 marked this conversation as resolved.
Show resolved Hide resolved
private static let queue = DispatchQueue(label: "FlutterAuthProviders")

/// Retrieves the latest token for `type` by calling into Flutter via the plugin's method channel.
static func getToken(for type: AWSAuthorizationType) -> Result<String, Error> {
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify_api/ios/Classes/FlutterApiResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension Encodable {
}
}

class FlutterApiResponse {
enum FlutterApiResponse {
static func handleGraphQLErrorResponse(
flutterResult: @escaping FlutterResult,
errorResponse: GraphQLResponseError<String>
Expand Down
6 changes: 4 additions & 2 deletions packages/amplify_api/ios/Classes/FlutterRestApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import Amplify
import AmplifyPlugins
import AWSCore

public class FlutterRestApi {
public enum FlutterRestApi {
private static func restFunctionHelper(
methodName: String,
flutterResult: @escaping FlutterResult,
request: [String: Any], function: (RESTRequest, RESTOperation.ResultListener?) -> RESTOperation ) {
request: [String: Any],
function: (RESTRequest, RESTOperation.ResultListener?) -> RESTOperation
) {
do {
let cancelToken = try FlutterApiRequest.getCancelToken(methodChannelRequest: request)
let restRequest = try FlutterApiRequest.getRestRequest(methodChannelRequest: request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public struct FlutterSerializedRestResponse {
init(statusCode: Int, headers: [AnyHashable: Any], data: Data?) {
let stringHeaders = headers
.filter { $0.key is String }
.compactMapValues { $0 as? String } as? [String: String]
.compactMapValues { $0 as? String }
self.statusCode = statusCode
self.headers = stringHeaders ?? [:]
self.headers = stringHeaders as? [String: String] ?? [:]
self.data = data
}

Expand Down
34 changes: 21 additions & 13 deletions packages/amplify_api/ios/Classes/FlutterURLSessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,42 @@ class FlutterURLSessionBehaviorDelegate: NSObject, URLSessionBehaviorDelegate {
}

extension FlutterURLSessionBehaviorDelegate: URLSessionDelegate {
@objc public func urlSession(_ session: URLSession,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping AuthChallengeDispositionHandler) {
@objc public func urlSession(
_ session: URLSession,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping AuthChallengeDispositionHandler
) {
completionHandler(.performDefaultHandling, nil)
}
}

extension FlutterURLSessionBehaviorDelegate: URLSessionTaskDelegate {
@objc public func urlSession(_ session: URLSession,
task: URLSessionTask,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping AuthChallengeDispositionHandler) {
@objc public func urlSession(
_ session: URLSession,
task: URLSessionTask,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping AuthChallengeDispositionHandler
) {
completionHandler(.performDefaultHandling, nil)
}

@objc public func urlSession(_ session: URLSession,
task: URLSessionTask,
didCompleteWithError error: Error?) {
@objc public func urlSession(
_ session: URLSession,
task: URLSessionTask,
didCompleteWithError error: Error?
) {
urlSessionBehavior(session,
dataTaskBehavior: task,
didCompleteWithError: error)
}
}

extension FlutterURLSessionBehaviorDelegate: URLSessionDataDelegate {
@objc public func urlSession(_ session: URLSession,
dataTask: URLSessionDataTask,
didReceive data: Data) {
@objc public func urlSession(
_ session: URLSession,
dataTask: URLSessionDataTask,
didReceive data: Data
) {
urlSessionBehavior(session,
dataTaskBehavior: dataTask,
didReceive: data)
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify_api/ios/Classes/OperationsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import Foundation
import Amplify

public class OperationsManager {
public enum OperationsManager {
/// Prevents concurrent access to arrays.
private static let queue = DispatchQueue(label: "com.amazonaws.flutter.OperationsManager.concurrency")

Expand Down
Loading