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..9d0af0e --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,64 @@ +# Minimal SwiftLint configuration +# SwiftFormat handles all formatting, so SwiftLint focuses on code quality and best practices + +disabled_rules: + - line_length + - opening_brace + - function_parameter_count + - nesting + - large_tuple + - type_name + - force_unwrapping + - blanket_disable_command + +opt_in_rules: + - array_init + - contains_over_first_not_nil + - convenience_type + - discouraged_assert + - discouraged_object_literal + - empty_count + - empty_string + - empty_xctest_method + - explicit_init + - fatal_error_message + - first_where + - force_cast + - force_try + - implicit_return + - joined_default_parameter + - last_where + - legacy_random + - lower_acl_than_parent + - multiline_function_chains + - multiline_parameters + - multiline_parameters_brackets + - no_fallthrough_only + - operator_usage_whitespace + - overridden_super_call + - prohibited_super_call + - redundant_nil_coalescing + - single_test_class + - sorted_first_last + - static_operator + - 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 + +multiline_parameters: + allows_single_line: false + +excluded: + - .build + - "**/.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 }