mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Merge pull request #148 from mattrubin/lint
SwiftLint fixes and updates
This commit is contained in:
commit
dcf36660aa
4
.hound.yml
Normal file
4
.hound.yml
Normal file
@ -0,0 +1,4 @@
|
||||
# Configuration for Hound (https://houndci.com)
|
||||
|
||||
swiftlint:
|
||||
config_file: .swiftlint.yml
|
||||
@ -3,28 +3,73 @@ disabled_rules:
|
||||
- force_cast
|
||||
- force_try
|
||||
- function_body_length
|
||||
- identifier_name
|
||||
- redundant_optional_initialization
|
||||
- type_body_length
|
||||
|
||||
opt_in_rules:
|
||||
- array_init
|
||||
- attributes
|
||||
- closure_end_indentation
|
||||
- closure_spacing
|
||||
- collection_alignment
|
||||
- conditional_returns_on_newline
|
||||
- contains_over_first_not_nil
|
||||
- convenience_type
|
||||
- discouraged_object_literal
|
||||
- discouraged_optional_boolean
|
||||
- discouraged_optional_collection
|
||||
- empty_count
|
||||
- empty_string
|
||||
- empty_xctest_method
|
||||
- explicit_enum_raw_value
|
||||
- explicit_init
|
||||
- extension_access_modifier
|
||||
- fallthrough
|
||||
- fatal_error_message
|
||||
- first_where
|
||||
- function_default_parameter_at_end
|
||||
- identical_operands
|
||||
- implicitly_unwrapped_optional
|
||||
- joined_default_parameter
|
||||
- last_where
|
||||
- legacy_random
|
||||
- literal_expression_end_indentation
|
||||
- lower_acl_than_parent
|
||||
- modifier_order
|
||||
- multiline_arguments
|
||||
- multiline_function_chains
|
||||
- multiline_literal_brackets
|
||||
- nslocalizedstring_key
|
||||
- overridden_super_call
|
||||
- override_in_extension
|
||||
- private_action
|
||||
- private_outlet
|
||||
- prohibited_super_call
|
||||
- quick_discouraged_call
|
||||
- quick_discouraged_focused_test
|
||||
- quick_discouraged_pending_test
|
||||
- redundant_nil_coalescing
|
||||
- redundant_type_annotation
|
||||
- sorted_first_last
|
||||
- strict_fileprivate
|
||||
- switch_case_on_newline
|
||||
- toggle_bool
|
||||
- unavailable_function
|
||||
- untyped_error_in_catch
|
||||
- unused_import
|
||||
- unused_private_declaration
|
||||
- vertical_parameter_alignment_on_call
|
||||
- xct_specific_matcher
|
||||
- yoda_condition
|
||||
|
||||
excluded:
|
||||
- Carthage
|
||||
- External
|
||||
|
||||
line_length:
|
||||
ignores_function_declarations: true
|
||||
|
||||
trailing_comma:
|
||||
mandatory_comma: true
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ public struct Signature {
|
||||
func makeUnsafeSignature() -> Result<UnsafeMutablePointer<git_signature>, NSError> {
|
||||
var signature: UnsafeMutablePointer<git_signature>? = nil
|
||||
let time = git_time_t(self.time.timeIntervalSince1970) // Unix epoch time
|
||||
let offset: Int32 = Int32(timeZone.secondsFromGMT(for: self.time) / 60)
|
||||
let offset = Int32(timeZone.secondsFromGMT(for: self.time) / 60)
|
||||
let signatureResult = git_signature_new(&signature, name, email, time, offset)
|
||||
guard signatureResult == GIT_OK.rawValue, let signatureUnwrap = signature else {
|
||||
let err = NSError(gitError: signatureResult, pointOfFailure: "git_signature_new")
|
||||
|
||||
@ -95,7 +95,7 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt
|
||||
}
|
||||
|
||||
/// A git repository.
|
||||
final public class Repository {
|
||||
public final class Repository {
|
||||
|
||||
// MARK: - Creating Repositories
|
||||
|
||||
@ -104,7 +104,7 @@ final public class Repository {
|
||||
/// URL - The URL of the repository.
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
class public func create(at url: URL) -> Result<Repository, NSError> {
|
||||
public class func create(at url: URL) -> Result<Repository, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = url.withUnsafeFileSystemRepresentation {
|
||||
git_repository_init(&pointer, $0, 0)
|
||||
@ -123,7 +123,7 @@ final public class Repository {
|
||||
/// URL - The URL of the repository.
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
class public func at(_ url: URL) -> Result<Repository, NSError> {
|
||||
public class func at(_ url: URL) -> Result<Repository, NSError> {
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = url.withUnsafeFileSystemRepresentation {
|
||||
git_repository_open(&pointer, $0)
|
||||
@ -148,11 +148,12 @@ final public class Repository {
|
||||
/// checkoutProgress - A block that's called with the progress of the checkout.
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
class public func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
|
||||
public class func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
|
||||
credentials: Credentials = .default, checkoutStrategy: CheckoutStrategy = .Safe,
|
||||
checkoutProgress: CheckoutProgressBlock? = nil) -> Result<Repository, NSError> {
|
||||
var options = cloneOptions(
|
||||
bare: bare, localClone: localClone,
|
||||
bare: bare,
|
||||
localClone: localClone,
|
||||
fetchOptions: fetchOptions(credentials: credentials),
|
||||
checkoutOptions: checkoutOptions(strategy: checkoutStrategy, progress: checkoutProgress))
|
||||
|
||||
@ -704,8 +705,6 @@ final public class Repository {
|
||||
// MARK: - Diffs
|
||||
|
||||
public func diff(for commit: Commit) -> Result<Diff, NSError> {
|
||||
typealias Delta = Diff.Delta
|
||||
|
||||
guard !commit.parents.isEmpty else {
|
||||
// Initial commit in a repository
|
||||
return self.diff(from: nil, to: commit.oid)
|
||||
@ -847,8 +846,7 @@ final public class Repository {
|
||||
}
|
||||
|
||||
private func processDiffDeltas(_ diffResult: OpaquePointer) -> Result<[Diff.Delta], NSError> {
|
||||
typealias Delta = Diff.Delta
|
||||
var returnDict = [Delta]()
|
||||
var returnDict = [Diff.Delta]()
|
||||
|
||||
let count = git_diff_num_deltas(diffResult)
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ final class Fixtures {
|
||||
// MARK: Lifecycle
|
||||
|
||||
class var sharedInstance: Fixtures {
|
||||
struct Singleton {
|
||||
enum Singleton {
|
||||
static let instance = Fixtures()
|
||||
}
|
||||
return Singleton.instance
|
||||
|
||||
@ -11,6 +11,8 @@ import SwiftGit2
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
// swiftlint:disable cyclomatic_complexity
|
||||
|
||||
class RepositorySpec: QuickSpec {
|
||||
override func spec() {
|
||||
describe("Repository.Type.at(_:)") {
|
||||
@ -752,7 +754,8 @@ class RepositorySpec: QuickSpec {
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.author).to(equal(signature))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.committer).to(equal(signature))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.message).to(equal("\(message)\n"))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.oid.description).to(equal("7d6b2d7492f29aee48022387f96dbfe996d435fe"))
|
||||
expect(repo.commits(in: updatedBranch).next()?.value?.oid.description)
|
||||
.to(equal("7d6b2d7492f29aee48022387f96dbfe996d435fe"))
|
||||
|
||||
// should be clean now
|
||||
let newStatus = repo.status()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user