Skip to content

Commit 50db480

Browse files
authored
Merge branch 'woomob-965-new-endpoints' into woomob-965-yosemite-update
2 parents 0479497 + 9acef85 commit 50db480

File tree

88 files changed

+2011
-238
lines changed

Some content is hidden

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

88 files changed

+2011
-238
lines changed

.buildkite/commands/build-for-testing.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ echo "--- :hammer_and_wrench: Building"
1818
bundle exec fastlane build_for_testing
1919

2020
echo "--- :arrow_up: Upload Build Products"
21-
tar -cf build-products.tar DerivedData/Build/Products/
21+
tar -cf build-products.tar DerivedData/Build/Products/ DerivedData/Index.noindex/DataStore/
2222
buildkite-agent artifact upload build-products.tar
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash -eu
2+
3+
if .buildkite/commands/should-skip-job.sh --job-type validation; then
4+
exit 0
5+
fi
6+
7+
### Prepare
8+
9+
echo '--- 📦 Downloading Build Artifacts'
10+
buildkite-agent artifact download build-products.tar .
11+
tar -xf build-products.tar
12+
13+
### Run the Tests
14+
15+
PERIPHERY_OUTPUT_FILE="periphery-errors.txt"
16+
17+
echo '+++ :zombie: Detecting unused code'
18+
set +e
19+
# This is the script in the root.
20+
./Scripts/Periphery/setup-and-run-periphery.sh \
21+
--strict --quiet --skip-build --index-store-path 'DerivedData/Index.noindex/DataStore/' \
22+
--write-results "$PERIPHERY_OUTPUT_FILE"
23+
TESTS_EXIT_STATUS=$?
24+
set -e
25+
26+
# Handle the result of the periphery scan
27+
if [[ "$TESTS_EXIT_STATUS" -ne 0 ]]; then
28+
echo '😱 Unused code detected!'
29+
echo ''
30+
echo '💡 You can run Periphery locally by calling `setup-and-run-periphery.sh` from `./Scripts/Periphery/` in the repo.'
31+
echo ''
32+
echo 'If you think there is a false positive violation, please check the known issues of Periphery at https://github.com/peripheryapp/periphery/issues.'
33+
echo 'If you think a violation is valid but it should be surpressed for any reason, please apply the `// periphery: ignore - {your-reason-here}` comment.'
34+
echo ''
35+
# Add the periphery errors as a Buildkite annotation
36+
(echo "### Periphery found unused code"; echo ''; echo '```'; cat "$PERIPHERY_OUTPUT_FILE"; echo ''; echo '```') \
37+
| buildkite-agent annotate --context periphery --style error
38+
else
39+
echo '😊 No unused code found.'
40+
buildkite-agent annotate --context periphery --style success 'No unused code found by Periphery :tada:'
41+
fi
42+
43+
echo '--- 🚦 Report Exit code'
44+
exit $TESTS_EXIT_STATUS

.buildkite/pipeline.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ steps:
7979
agents:
8080
queue: linter
8181

82+
- label: "🧟 Detect unused code"
83+
command: ".buildkite/commands/run-periphery.sh"
84+
depends_on: build
85+
plugins: [$CI_TOOLKIT]
86+
notify:
87+
- github_commit_status:
88+
context: Periphery - Detect unused code
89+
8290
- label: 🧹 Lint Translations
8391
command: gplint /workdir/WooCommerce/Resources/AppStoreStrings.pot
8492
plugins:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ WooCommerce/WooCommerceScreenshots/Mocks/vendor/
102102
Modules/.build
103103
Modules/.swiftpm/configuration/registries.json
104104
Modules/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
105+
106+
# Periphery install
107+
vendor/Periphery/

.periphery.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This option tells Periphery to not report any Swift code as unused if it's accessible from Objective-C. This includes any class that inherits from NSObject, and any method or property marked with the @objc or @objcMembers attribute.
2+
# Woocommerce-ios, is a mixed Swift and Objective-C project. Swift code is often called from Objective-C and vice-versa. Without this flag, Periphery would incorrectly flag Swift code that is only used by Objective-C parts of the app as "unused," which would be a false positive. Setting this to true is essential for getting accurate results in a mixed-language codebase.
3+
retain_objc_accessible: true
4+
5+
# This option prevents Periphery from flagging unused parameters in protocol method implementations.
6+
# Often, a protocol will define a method with parameters that are needed by some, but not all, conforming types. If a specific implementation doesn't need to use a parameter, Swift still requires that the method signature matches the protocol exactly. Periphery would normally see this unused parameter and flag it. However, removing it would cause a compile error because the method signature would no longer match the protocol. This flag tells Periphery to ignore these cases, avoiding false positives.
7+
retain_unused_protocol_func_params: true
8+
9+
# This option retains all code within a previews struct that conforms to SwiftUI's PreviewProvider protocol.
10+
# SwiftUI Previews are a powerful feature for UI development in Xcode. The code you write for previews is often not directly called from your main application target; it's used by Xcode's canvas. Periphery would see this and incorrectly mark the preview code as unused. This flag correctly tells Periphery to always keep preview provider code, which is the desired behavior.
11+
retain_swift_ui_previews: true
12+
13+
# This option disables the check for public declarations that are only used within their own module.
14+
# Normally, Periphery would suggest changing public to internal or private in these cases to reduce the public API surface of a module.
15+
disable_redundant_public_analysis: false
16+
17+
# By default, Periphery will scan all targets in your project, including test targets.
18+
# This can lead to false positives, as test code is not part of the main application.
19+
# This option tells Periphery to exclude all test targets from the scan, ensuring that only the application code is analyzed.
20+
exclude_tests: true
21+
22+
schemes:
23+
- WooCommerce
24+
25+
project: WooCommerce.xcworkspace
26+
27+
# Used for local run by `periphery scan`
28+
# This will not conflict with CI build configuration because of build skipping by `--skip-build` and `--index-store-path`
29+
build_arguments:
30+
- -xcconfig
31+
- config/WooCommerce.debug.xcconfig
32+
33+
# A baseline is used to manage the large number of warnings from a mature codebase.
34+
# It contains a snapshot of all "existing/acceptable" warnings. Periphery will ignore all
35+
# warnings in this file, allowing you to focus on new issues in pull requests.
36+
#
37+
# After fixing existing warnings, regenerate this file with:
38+
# periphery scan --write-baseline Scripts/Periphery/periphery_baseline.json
39+
baseline: Scripts/Periphery/periphery_baseline.json
40+
41+
exclude_targets:
42+
- GenerateCredentials
43+
- WooCommerceScreenshots
44+
- WordPressAuthenticator
45+
- WordPressAuthenticatorTests
46+
- WooCommerceTests
47+
- WooCommerceUITests
48+
- NotificationExtension
49+
- StoreWidgetsExtension
50+
- WatchWidgetsExtension
51+
- "Woo Watch App"
52+
- Fakes
53+
- XcodeTarget_WooCommerceTests
54+
- XcodeTarget_WooCommerceUITests
55+
- XcodeTarget_WordPressAuthenticatorTests
56+
57+
index_exclude:
58+
- Pods/*
59+
- vendor/**
60+
- BuildTools/.build/**
61+
- "**/Tests/*"
62+
- "**/Test*/*"
63+
- "docs/*"
64+
- "fastlane/*"
65+
- "config/*"
66+
- "**/*.xib"
67+
- "**/*.storyboard"
68+
- "**/*.generated.swift"

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
104104
case .pointOfSaleBarcodeScanningi2:
105105
return buildConfig == .localDeveloper || buildConfig == .alpha
106106
case .orderAddressMapSearch:
107-
return buildConfig == .localDeveloper || buildConfig == .alpha
107+
return true
108108
default:
109109
return true
110110
}

Modules/Sources/Networking/Mapper/JetpackConnectionDataMapper.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Foundation
55
///
66
struct JetpackConnectionDataMapper: Mapper {
77

8-
/// (Attempts) to extract the updated `currentUser` field from a given JSON Encoded response.
9-
///
108
func map(response: Data) throws -> JetpackConnectionData {
119
let decoder = JSONDecoder()
1210
return try decoder.decode(JetpackConnectionData.self, from: response)

Modules/Sources/NetworkingCore/Remote/Remote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public extension Remote {
370370
public static let firstPageNumber: Int = 1
371371
}
372372

373-
public enum PaginationHeaderKey {
373+
enum PaginationHeaderKey {
374374
public static let totalPagesCount = "x-wp-totalpages"
375375
public static let totalCount = "x-wp-total"
376376
}

Modules/Sources/Yosemite/Internal/NSOrderedSet+Array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

33
extension NSOrderedSet {
4-
func toArray<T>() -> [T] {
4+
public func toArray<T>() -> [T] {
55
guard let array = array as? [T] else {
66
return []
77
}

Modules/Sources/Yosemite/Model/Storage/Product+ReadOnlyConvertible.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import Storage
33

44
extension Storage.Product {
5-
var imagesArray: [Storage.ProductImage] {
5+
public var imagesArray: [Storage.ProductImage] {
66
return images?.toArray() ?? []
77
}
88
var tagsArray: [Storage.ProductTag] {

0 commit comments

Comments
 (0)