From 60765c488a3441f6ab2eeca3f8bd0402184fabe7 Mon Sep 17 00:00:00 2001 From: Otavio Cordeiro Date: Tue, 13 Jan 2026 12:10:26 -0300 Subject: [PATCH 1/3] Add SwiftLint and SwiftFormat --- .github/workflows/ci.yml | 43 +++++++++++ .github/workflows/swiftformat.yml | 22 ++++++ .github/workflows/swiftlint.yml | 22 ++++++ .swiftformat | 3 +- .swiftlint.yml | 76 +++++++++++++++++++ .../Extensions/TimeInterval+Extensions.swift | 10 +-- .../TranscriptionViewModel.swift | 2 +- 7 files changed, 171 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/swiftformat.yml create mode 100644 .github/workflows/swiftlint.yml create mode 100644 .swiftlint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..51f47a4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI + +on: + pull_request: + branches: [ main ] + types: [opened, synchronize, reopened] + push: + branches: [ main ] + +jobs: + build: + name: Build on macOS (${{ matrix.xcode-version }}) + runs-on: macos-latest + + strategy: + matrix: + xcode-version: [latest-stable, latest] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.xcode-version }} + + - name: Cache DerivedData + uses: actions/cache@v4 + with: + path: ~/Library/Developer/Xcode/DerivedData + key: ${{ runner.os }}-deriveddata-${{ hashFiles('**/*.xcodeproj/project.pbxproj') }} + restore-keys: | + ${{ runner.os }}-deriveddata- + + - name: Build + run: | + xcodebuild clean build \ + -project Stenographer.xcodeproj \ + -scheme Stenographer \ + -configuration Release \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_REQUIRED=NO diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml new file mode 100644 index 0000000..59dc5db --- /dev/null +++ b/.github/workflows/swiftformat.yml @@ -0,0 +1,22 @@ +name: SwiftFormat + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + swiftformat: + name: SwiftFormat + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install SwiftFormat + run: brew install swiftformat + + - name: Run SwiftFormat + run: swiftformat --lint . diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml new file mode 100644 index 0000000..af781e1 --- /dev/null +++ b/.github/workflows/swiftlint.yml @@ -0,0 +1,22 @@ +name: SwiftLint + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + swiftlint: + name: SwiftLint + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install SwiftLint + run: brew install swiftlint + + - name: Run SwiftLint + run: swiftlint lint --reporter github-actions-logging diff --git a/.swiftformat b/.swiftformat index 8403bd3..2f24b3a 100644 --- a/.swiftformat +++ b/.swiftformat @@ -25,6 +25,7 @@ --indent-case false --indent-strings false --xcode-indentation enabled +--wrap-conditions preserve # MARK: - Imports and Headers --import-grouping testable-last @@ -50,7 +51,7 @@ --ifdef indent # MARK: - SwiftUI and Modern Swift Features ---swift-version 6.0 +--swift-version 6.2 --sort-swiftui-properties first-appearance-sort --some-any true --short-optionals always diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..8a0458c --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,76 @@ +disabled_rules: + - vertical_parameter_alignment_on_call # Conflicts with SwiftFormat's --wrap-arguments before-first + - trailing_comma # SwiftFormat handles this with --trailing-commas never + - sorted_imports # SwiftFormat handles this with --import-grouping testable-last + - opening_brace # SwiftFormat handles brace placement with --allman false + - statement_position # SwiftFormat handles else/catch position with --else-position same-line + - closure_spacing # SwiftFormat handles closure spacing + - vertical_whitespace_between_cases # SwiftFormat handles with --enable sortSwitchCases + - indentation_width # SwiftFormat handles indentation with --indent 4 + - function_name_whitespace # SwiftFormat handles with --operator-func spaced + +opt_in_rules: + - array_init + - block_based_kvo + - closure_end_indentation + - contains_over_first_not_nil + - convenience_type + - discouraged_assert + - discouraged_object_literal + - discouraged_optional_boolean + - empty_count + - empty_string + - empty_xctest_method + - explicit_init + - extension_access_modifier + - fatal_error_message + - file_header + - file_length + - first_where + - force_cast + - force_try + - force_unwrapping + - implicit_return + - joined_default_parameter + - last_where + - legacy_random + - lower_acl_than_parent + - modifier_order + - multiline_function_chains + - multiline_parameters + - multiline_parameters_brackets + - no_fallthrough_only + - operator_usage_whitespace + - overridden_super_call + - private_action + - private_outlet + - private_unit_test + - prohibited_super_call + - redundant_nil_coalescing + - single_test_class + - sorted_first_last + - static_operator + - strong_iboutlet + - switch_case_alignment + - trailing_closure + - unavailable_function + - unneeded_parentheses_in_closure_argument + - unused_control_flow_label + - vertical_whitespace_closing_braces + - xct_specific_matcher + - xctfail_message + - yoda_condition + +private_outlet: + allow_private_set: true + +multiline_parameters: + allows_single_line: false + +excluded: + - .build + - DerivedData + - Pods + - Carthage + - .git + - node_modules diff --git a/Stenographer/Extensions/TimeInterval+Extensions.swift b/Stenographer/Extensions/TimeInterval+Extensions.swift index a5a2a63..0285729 100644 --- a/Stenographer/Extensions/TimeInterval+Extensions.swift +++ b/Stenographer/Extensions/TimeInterval+Extensions.swift @@ -4,12 +4,12 @@ extension TimeInterval { var srtTimecode: String { let totalMilliseconds = Int(self * 1000) - let ms = totalMilliseconds % 1000 + let milliseconds = totalMilliseconds % 1000 let totalSeconds = totalMilliseconds / 1000 - let s = totalSeconds % 60 - let m = (totalSeconds / 60) % 60 - let h = totalSeconds / 3600 + let seconds = totalSeconds % 60 + let minutes = (totalSeconds / 60) % 60 + let hours = totalSeconds / 3600 - return String(format: "%02d:%02d:%02d,%03d", h, m, s, ms) + return String(format: "%02d:%02d:%02d,%03d", hours, minutes, seconds, milliseconds) } } diff --git a/Stenographer/Views/Transcription/TranscriptionViewModel.swift b/Stenographer/Views/Transcription/TranscriptionViewModel.swift index 35ff17a..88cb38f 100644 --- a/Stenographer/Views/Transcription/TranscriptionViewModel.swift +++ b/Stenographer/Views/Transcription/TranscriptionViewModel.swift @@ -22,7 +22,7 @@ final class TranscriptionViewModel { var wordCount: Int { transcriptionText - .split(whereSeparator: { $0.isWhitespace || $0.isNewline }) + .split { $0.isWhitespace || $0.isNewline } .count } From 1fc9500870c89d9ae7629cfe811ca2de505aa85a Mon Sep 17 00:00:00 2001 From: Otavio Cordeiro Date: Wed, 14 Jan 2026 11:52:24 -0300 Subject: [PATCH 2/3] Update SwiftLint rules --- .swiftlint.yml | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 8a0458c..9d0af0e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,56 +1,46 @@ +# Minimal SwiftLint configuration +# SwiftFormat handles all formatting, so SwiftLint focuses on code quality and best practices + disabled_rules: - - vertical_parameter_alignment_on_call # Conflicts with SwiftFormat's --wrap-arguments before-first - - trailing_comma # SwiftFormat handles this with --trailing-commas never - - sorted_imports # SwiftFormat handles this with --import-grouping testable-last - - opening_brace # SwiftFormat handles brace placement with --allman false - - statement_position # SwiftFormat handles else/catch position with --else-position same-line - - closure_spacing # SwiftFormat handles closure spacing - - vertical_whitespace_between_cases # SwiftFormat handles with --enable sortSwitchCases - - indentation_width # SwiftFormat handles indentation with --indent 4 - - function_name_whitespace # SwiftFormat handles with --operator-func spaced + - line_length + - opening_brace + - function_parameter_count + - nesting + - large_tuple + - type_name + - force_unwrapping + - blanket_disable_command opt_in_rules: - array_init - - block_based_kvo - - closure_end_indentation - contains_over_first_not_nil - convenience_type - discouraged_assert - discouraged_object_literal - - discouraged_optional_boolean - empty_count - empty_string - empty_xctest_method - explicit_init - - extension_access_modifier - fatal_error_message - - file_header - - file_length - first_where - force_cast - force_try - - force_unwrapping - implicit_return - joined_default_parameter - last_where - legacy_random - lower_acl_than_parent - - modifier_order - multiline_function_chains - multiline_parameters - multiline_parameters_brackets - no_fallthrough_only - operator_usage_whitespace - overridden_super_call - - private_action - - private_outlet - - private_unit_test - prohibited_super_call - redundant_nil_coalescing - single_test_class - sorted_first_last - static_operator - - strong_iboutlet - switch_case_alignment - trailing_closure - unavailable_function @@ -61,14 +51,12 @@ opt_in_rules: - xctfail_message - yoda_condition -private_outlet: - allow_private_set: true - multiline_parameters: allows_single_line: false excluded: - .build + - "**/.build" - DerivedData - Pods - Carthage From 384aa97d78c31f8ed6aada3a392e504ee07d0ba2 Mon Sep 17 00:00:00 2001 From: Otavio Cordeiro Date: Wed, 14 Jan 2026 12:29:16 -0300 Subject: [PATCH 3/3] Remove ci.yml --- .github/workflows/ci.yml | 43 ---------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 51f47a4..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: CI - -on: - pull_request: - branches: [ main ] - types: [opened, synchronize, reopened] - push: - branches: [ main ] - -jobs: - build: - name: Build on macOS (${{ matrix.xcode-version }}) - runs-on: macos-latest - - strategy: - matrix: - xcode-version: [latest-stable, latest] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Xcode - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{ matrix.xcode-version }} - - - name: Cache DerivedData - uses: actions/cache@v4 - with: - path: ~/Library/Developer/Xcode/DerivedData - key: ${{ runner.os }}-deriveddata-${{ hashFiles('**/*.xcodeproj/project.pbxproj') }} - restore-keys: | - ${{ runner.os }}-deriveddata- - - - name: Build - run: | - xcodebuild clean build \ - -project Stenographer.xcodeproj \ - -scheme Stenographer \ - -configuration Release \ - CODE_SIGN_IDENTITY="" \ - CODE_SIGNING_REQUIRED=NO