Skip to content

Commit

Permalink
Merge pull request #5 from FelixHerrmann/feature/swiftlint
Browse files Browse the repository at this point in the history
[Feature] SwiftLint
  • Loading branch information
FelixHerrmann authored Sep 13, 2023
2 parents a78fb1f + e101961 commit 1fb0030
Show file tree
Hide file tree
Showing 19 changed files with 493 additions and 403 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: SwiftLint

on:
push:
branches:
- master
paths:
- '.github/workflows/swiftlint.yml'
- '**/.swiftlint.yml'
- '**.swift'
pull_request:
branches:
- master
paths:
- '.github/workflows/swiftlint.yml'
- '**/.swiftlint.yml'
- '**.swift'
workflow_dispatch:

jobs:
swiftlint:
name: SwiftLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: norio-nomura/action-swiftlint@3.2.1
with:
args: --strict
103 changes: 103 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
disabled_rules:
- nesting
- trailing_comma
opt_in_rules:
- anonymous_argument_in_multiline_closure
- array_init
- attributes
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- comma_inheritance
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- convenience_type
- discouraged_assert
- discouraged_none_name
- discouraged_object_literal
- discouraged_optional_boolean
- discouraged_optional_collection
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- expiring_todo
- explicit_init
- file_header
- file_name
- file_name_no_space
- first_where
- flatmap_over_map_reduce
- force_unwrapping
- identical_operands
- implicitly_unwrapped_optional
- indentation_width
- joined_default_parameter
- last_where
- legacy_multiple
- legacy_objc_type
- let_var_whitespace
- literal_expression_end_indentation
- local_doc_comment
- lower_acl_than_parent
- modifier_order
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- no_extension_access_modifier
- nslocalizedstring_key
- number_separator
- operator_usage_whitespace
- optional_enum_case_matching
- overridden_super_call
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- prefer_zero_over_explicit_init
- prohibited_super_call
- raw_value_for_camel_cased_codable_enum
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- return_value_from_void_function
- self_binding
- shorthand_optional_binding
- sorted_first_last
- static_operator
- toggle_bool
- trailing_closure
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- weak_delegate
- yoda_condition

analyzer_rules:
- unused_declaration
- unused_import

identifier_name:
allowed_symbols:
- '_'
excluded:
- x
- y

line_length:
- 130
- 200

trailing_whitespace:
ignores_empty_lines: true

type_name:
allowed_symbols:
- '_'
11 changes: 7 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ let package = Package(
platforms: [
.macOS(.v10_10),
.iOS(.v9),
.tvOS(.v9)
.tvOS(.v9),
],
products: [
.library(
name: "FHPropertyWrappers",
targets: ["FHPropertyWrappers"]),
targets: ["FHPropertyWrappers"]
),
],
dependencies: [],
targets: [
.target(
name: "FHPropertyWrappers",
dependencies: []),
dependencies: []
),
.testTarget(
name: "FHPropertyWrappersTests",
dependencies: ["FHPropertyWrappers"]),
dependencies: ["FHPropertyWrappers"]
),
]
)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFelixHerrmann%2FFHPropertyWrappers%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/FelixHerrmann/FHPropertyWrappers)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFelixHerrmann%2FFHPropertyWrappers%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/FelixHerrmann/FHPropertyWrappers)
[![Xcode Build](https://github.com/FelixHerrmann/FHPropertyWrappers/actions/workflows/xcodebuild.yml/badge.svg)](https://github.com/FelixHerrmann/FHPropertyWrappers/actions/workflows/xcodebuild.yml)
[![SwiftLint](https://github.com/FelixHerrmann/FHPropertyWrappers/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/FelixHerrmann/FHPropertyWrappers/actions/workflows/swiftlint.yml)

Some useful Swift Property Wrappers.

Expand Down
4 changes: 4 additions & 0 deletions Sources/FHPropertyWrappers/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
opt_in_rules:
- explicit_acl
- fatal_error_message
- missing_docs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// swiftlint:disable:this file_name

import Foundation
import Security


// MARK: - _KeychainError

internal struct _KeychainError: Error {

internal let _status: OSStatus

internal init(status: OSStatus) {
Expand All @@ -14,8 +12,7 @@ internal struct _KeychainError: Error {
}

extension _KeychainError: CustomDebugStringConvertible {

var debugDescription: String {
internal var debugDescription: String {
switch _status {
case errSecNotAvailable:
return "KeychainError: \(_status) (not available)"
Expand All @@ -39,10 +36,9 @@ extension _KeychainError: CustomDebugStringConvertible {
}
}


// MARK: - Keychain Query

internal func _KeychainQuery(key: SecureStoreKey, accessibility: SecureStoreAccessibility) -> [CFString: Any] {
internal func _keychainQuery(key: SecureStoreKey, accessibility: SecureStoreAccessibility) -> [CFString: Any] {
#if !SWIFT_PACKAGE // kSecUseDataProtectionKeychain doesn't work outside of an application
if #available(iOS 13.0, macOS 10.15, *) {
return [
Expand All @@ -60,10 +56,9 @@ internal func _KeychainQuery(key: SecureStoreKey, accessibility: SecureStoreAcce
]
}


// MARK: - Keychain Actions

internal func _KeychainGet(query: [CFString: Any]) throws -> Data? {
internal func _keychainGet(query: [CFString: Any]) throws -> Data? {
var query = query
query[kSecReturnData] = true

Expand All @@ -80,7 +75,7 @@ internal func _KeychainGet(query: [CFString: Any]) throws -> Data? {
}
}

internal func _KeychainSet(value: Data?, query: [CFString: Any]) throws {
internal func _keychainSet(value: Data?, query: [CFString: Any]) throws {
var query = query

let itemExists = SecItemCopyMatching(query as CFDictionary, nil) == errSecSuccess
Expand All @@ -102,7 +97,7 @@ internal func _KeychainSet(value: Data?, query: [CFString: Any]) throws {
}
}

internal func _KeychainDelete(query: [CFString: Any]) throws {
internal func _keychainDelete(query: [CFString: Any]) throws {
let status = SecItemDelete(query as CFDictionary)

if status != errSecSuccess && status != errSecItemNotFound {
Expand Down
Loading

0 comments on commit 1fb0030

Please sign in to comment.