Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
10 changes: 1 addition & 9 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ disabled_rules:
- cyclomatic_complexity
- file_length
- syntactic_sugar
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why the specific changes to linter rules in this file?

Also, for simplicity, we typically keep the same linter rules in SDK and in smithy-swift. So if we do change rules here, there should be a 2nd PR to change them there as well.

- unused_capture_list
- nesting
- operator_whitespace
- function_name_whitespace
- large_tuple
- trailing_comma
- non_optional_string_data_conversion

opt_in_rules:
- empty_count
- sorted_imports
- unused_imports

# configurable rules can be customized from this configuration file
force_cast: warning
Expand All @@ -46,11 +44,6 @@ function_body_length:
error: 150
generic_type_name:
max_length: 48
identifier_name:
excluded:
- id
- of
- or
line_length:
warning: 120
error: 160
Expand All @@ -59,5 +52,4 @@ opening_brace: error
return_arrow_whitespace: error
statement_position:
severity: error
todo: warning
trailing_semicolon: error
53 changes: 53 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
#
# lint.sh
# aws-sdk-swift
#
# Created by Felix, Anthony on 1/23/26.
#
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Replace the header with the standard Amazon header. Example:
https://github.com/awslabs/aws-sdk-swift/blob/main/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/AWSClientConfigDefaultsProvider.swift#L1-L6

Alternatively, you can simply delete the header entirely.


# Standard brew path setup
export PATH="$PATH:/opt/homebrew/bin:/usr/local/bin"

# Unset AWS_SWIFT_SDK_USE_LOCAL_DEPS to use remote dependencies instead of local ones
unset AWS_SWIFT_SDK_USE_LOCAL_DEPS
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we want to do this for a locally-run development script, since SDK developers are typically using a local copy of smithy-swift with local SDK. If you've made local SDK changes that have corresponding smithy-swift changes, the xcodebuild initiated below will fail.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Okay, I didn't think about developers making their own changes if they used a copy of the SDK locally, I'll change it so leaves the deps alone if they were set by the developer. That way it's a choice on their end.


LOG_FILE="xcodebuild.log"

echo "Step 1: Running standard SwiftLint..."
swiftlint lint --strict

echo "Step 2: Preparing minimal build for analyzer..."
# Create backup of Services directory
if [ -d "Sources/Services" ]; then
echo "Backing up Services directory..."
mv Sources/Services Sources/Services.backup
fi

# Create empty Services directory for CLI tool
mkdir -p Sources/Services

# Generate minimal package manifest without service clients
cd AWSSDKSwiftCLI
swift run AWSSDKSwiftCLI generate-package-manifest ..
cd ..

echo "Step 3: Building minimal project for analyzer..."
if xcodebuild -scheme aws-sdk-swift-Package -destination platform=macOS > "$LOG_FILE" 2>&1; then
echo "✅ Build completed successfully"

echo "Step 4: Running SwiftLint Analyze (this may take a few minutes)..."
timeout 300 swiftlint analyze --compiler-log-path "$LOG_FILE" || echo "⚠️ SwiftLint Analyze timed out after 5 minutes"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the reason for the 5 minute timeout? I generally disfavor setting timeouts unless they're there to address an operational problem, which I don't think we have here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The timeout I added as a just in case for local runs by the developer, but thinking twice about it now I think this should be more on the developer to set if they want to.

else
echo "⚠️ Build failed, skipping SwiftLint Analyze step"
echo "Check $LOG_FILE for build errors"
fi

# Restore Services directory
if [ -d "Sources/Services.backup" ]; then
echo "Restoring Services directory..."
rm -rf Sources/Services
mv Sources/Services.backup Sources/Services
fi

echo "✅ Linting complete!"
Loading