Skip to content

Commit

Permalink
Update for 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
rudrankriyam committed Feb 4, 2023
1 parent 9e81c1e commit c16aa60
Show file tree
Hide file tree
Showing 33 changed files with 855 additions and 720 deletions.
119 changes: 119 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
included:
- Plugins
- Source
- Tests
excluded:
- Tests/SwiftLintFrameworkTests/Resources
analyzer_rules:
- unused_declaration
- unused_import
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- discouraged_none_name
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- empty_xctest_method
- enum_case_associated_values_count
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_header
- file_name
- first_where
- flatmap_over_map_reduce
- identical_operands
- joined_default_parameter
- last_where
- legacy_multiple
- literal_expression_end_indentation
- local_doc_comment
- lower_acl_than_parent
- modifier_order
- nimble_operator
- nslocalizedstring_key
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- private_action
- private_outlet
- prohibited_interface_builder
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- return_value_from_void_function
- single_test_class
- sorted_first_last
- sorted_imports
- static_operator
- strong_iboutlet
- test_case_accessibility
- toggle_bool
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- xct_specific_matcher
- yoda_condition

identifier_name:
excluded:
- id
large_tuple: 3
number_separator:
minimum_length: 5
file_name:
excluded:
- SwiftSyntax+SwiftLint.swift
- GeneratedTests.swift
- TestHelpers.swift

function_body_length: 60
type_body_length: 400

custom_rules:
rule_id:
included: Source/SwiftLintFramework/Rules/.+/\w+\.swift
name: Rule ID
message: Rule IDs must be all lowercase, snake case and not end with `rule`
regex: identifier:\s*("\w+_rule"|"\S*[^a-z_]\S*")
severity: error
fatal_error:
name: Fatal Error
excluded: "Tests/*"
message: Prefer using `queuedFatalError` over `fatalError` to avoid leaking compiler host machine paths.
regex: \bfatalError\b
match_kinds:
- identifier
severity: error
rule_test_function:
included: Tests/SwiftLintFrameworkTests/RulesTests.swift
name: Rule Test Function
message: Rule Test Function mustn't end with `rule`
regex: func\s*test\w+(r|R)ule\(\)
severity: error

unused_import:
always_keep_imports:
- SwiftSyntaxBuilder # we can't detect uses of string interpolation of swift syntax nodes
34 changes: 34 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"object": {
"pins": [
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "10bc670db657d11bdd561e07de30a9041311b2b1",
"version": "1.1.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
},
{
"package": "SwiftLintPlugin",
"repositoryURL": "https://github.com/lukepistrol/SwiftLintPlugin",
"state": {
"branch": null,
"revision": "f69b412a765396d44dc9f4788a5b79919c1ca9e3",
"version": "0.2.2"
}
}
]
},
"version": 1
}
33 changes: 11 additions & 22 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,15 @@
import PackageDescription

let package = Package(
name: "QuoteKit",
platforms: [.iOS(.v13), .macOS(.v11), .tvOS(.v13), .watchOS(.v6)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "QuoteKit",
targets: ["QuoteKit"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "QuoteKit",
dependencies: []),
.testTarget(
name: "QuoteKitTests",
dependencies: ["QuoteKit"]),
]
name: "QuoteKit",
platforms: [.iOS(.v13), .macOS(.v11), .tvOS(.v13), .watchOS(.v6)],
products: [.library(name: "QuoteKit", targets: ["QuoteKit"])],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/lukepistrol/SwiftLintPlugin", from: "0.2.2")
],
targets: [
.target(name: "QuoteKit", dependencies: [], plugins: [.plugin(name: "SwiftLint", package: "SwiftLintPlugin")]),
.testTarget(name: "QuoteKitTests", dependencies: ["QuoteKit"]),
]
)
86 changes: 43 additions & 43 deletions Sources/QuoteKit/APIs/AuthorAPIs.swift
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
//
// File.swift
//
// AuthorAPIs.swift
// QuoteKit
//
// Created by Rudrank Riyam on 03/10/21.
//

import Foundation

public extension QuoteKit {
static func authorImage(with slug: String, size: Int = 700) -> URL {
QuotableEndpoint(.authorProfile(size, slug), host: .images).url
}

static func author(id: String) async throws -> Author {
try await execute(with: QuotableEndpoint(.author(id)))
static func authorImage(with slug: String, size: Int = 700) -> URL {
QuotableEndpoint(.authorProfile(size, slug), host: .images).url
}

static func author(id: String) async throws -> Author {
try await execute(with: QuotableEndpoint(.author(id)))
}

static func authors(slugs: [String]? = nil,
sortBy: AuthorsAndTagsSortType? = nil,
order: QuotableListOrder? = nil,
limit: Int = 20,
page: Int = 1) async throws -> Authors {

let queryItems = authorsParameters(slugs: slugs, sortBy: sortBy, order: order, limit: limit, page: page)

return try await execute(with: QuotableEndpoint(.authors, queryItems: queryItems))
}

private static func authorsParameters(slugs: [String]? = nil,
sortBy: AuthorsAndTagsSortType? = nil,
order: QuotableListOrder? = nil,
limit: Int = 20,
page: Int = 1) -> [URLQueryItem] {

var queryItems: [URLQueryItem] = []

queryItems.append(.limit(limit))
queryItems.append(.page(page))

if let slugs = slugs {
queryItems.append(.slugs(slugs))
}

static func authors(slugs: [String]? = nil,
sortBy: AuthorsAndTagsSortType? = nil,
order: QuotableListOrder? = nil,
limit: Int = 20,
page: Int = 1) async throws -> Authors {

let queryItems = authorsParameters(slugs: slugs, sortBy: sortBy, order: order, limit: limit, page: page)

return try await execute(with: QuotableEndpoint(.authors, queryItems: queryItems))

if let sortBy = sortBy {
queryItems.append(.sortBy(sortBy))
}

private static func authorsParameters(slugs: [String]? = nil,
sortBy: AuthorsAndTagsSortType? = nil,
order: QuotableListOrder? = nil,
limit: Int = 20,
page: Int = 1) -> [URLQueryItem] {

var queryItems: [URLQueryItem] = []

queryItems.append(.limit(limit))
queryItems.append(.page(page))

if let slugs = slugs {
queryItems.append(.slugs(slugs))
}

if let sortBy = sortBy {
queryItems.append(.sortBy(sortBy))
}

if let order = order {
queryItems.append(.order(order))
}

return queryItems

if let order = order {
queryItems.append(.order(order))
}

return queryItems
}
}
Loading

0 comments on commit c16aa60

Please sign in to comment.