Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Remove redundant access modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
siemensikkema committed May 3, 2019
1 parent 765bab6 commit a1ec33e
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Sources/Sugar/Commands/SeederCommand/Seedable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public protocol Seedable: Model {
}

public extension Seedable {
public static var arguments: [CommandArgument] {
static var arguments: [CommandArgument] {
return []
}

public static var options: [CommandOption] {
static var options: [CommandOption] {
return []
}
}
2 changes: 1 addition & 1 deletion Sources/Sugar/Helpers/Array.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public extension Array {
public subscript(safe index: Int) -> Element? {
subscript(safe index: Int) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
2 changes: 1 addition & 1 deletion Sources/Sugar/Helpers/Bool.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public extension Bool {
public init(from string: String) {
init(from string: String) {
self = ["1", "true"].contains(string.lowercased())
}
}
2 changes: 1 addition & 1 deletion Sources/Sugar/Helpers/CommandConfig.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vapor

public extension CommandConfig {
public mutating func use(_ list: [String: Command]) {
mutating func use(_ list: [String: Command]) {
for item in list {
self.use(item.value, as: item.key)
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/Sugar/Helpers/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,51 @@ public extension Date {
static let hourInSec = 3600
static let minInSec = 60

public static func startOfMonth() -> Date? {
static func startOfMonth() -> Date? {
return Date().startOfMonth()
}

public static func endOfMonth() -> Date? {
static func endOfMonth() -> Date? {
return Date().endOfMonth()
}

public func startOfMonth(calendar: Calendar = .current) -> Date? {
func startOfMonth(calendar: Calendar = .current) -> Date? {
return calendar.date(
from: calendar.dateComponents([.year, .month],
from: calendar.startOfDay(for: self))
)
}

public func endOfMonth(calendar: Calendar = .current) -> Date? {
func endOfMonth(calendar: Calendar = .current) -> Date? {
guard let startOfMonth = self.startOfMonth() else { return nil }
return calendar.date(
byAdding: DateComponents(month: 1, day: -1),
to: startOfMonth
)
}

public func add(days: Int, calendar: Calendar = .current) -> Date? {
func add(days: Int, calendar: Calendar = .current) -> Date? {
return calendar.date(
byAdding: DateComponents(day: days),
to: self
)
}

public func sub(days: Int, calendar: Calendar = .current) -> Date? {
func sub(days: Int, calendar: Calendar = .current) -> Date? {
return calendar.date(
byAdding: DateComponents(day: -days),
to: self
)
}

public func add(hours: Int, calendar: Calendar = .current) -> Date? {
func add(hours: Int, calendar: Calendar = .current) -> Date? {
return calendar.date(
byAdding: DateComponents(hour: hours),
to: self
)
}

public func sub(hours: Int, calendar: Calendar = .current) -> Date? {
func sub(hours: Int, calendar: Calendar = .current) -> Date? {
return calendar.date(
byAdding: DateComponents(hour: -hours),
to: self
Expand All @@ -66,7 +66,7 @@ public extension Date {
/// - minute: Int
/// - second: Int
/// - Returns: Date?
public func dateBySetting(
func dateBySetting(
hour: Int,
minute: Int,
second: Int,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sugar/Helpers/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ public extension Environment {
case keyNotFound(key: String)
}

public static func get(_ key: String, _ fallback: String) -> String {
static func get(_ key: String, _ fallback: String) -> String {
return ProcessInfo.processInfo.environment[key] ?? fallback
}

public static func assertGet(_ key: String) throws -> String {
static func assertGet(_ key: String) throws -> String {
guard let value = Environment.get(key) else {
throw Environment.EnvironmentError.keyNotFound(key: key)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Sugar/Helpers/Future.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import Vapor

public extension Future {
public func `try`(_ callback: @escaping (Expectation) throws -> Void) -> Future<T> {
func `try`(_ callback: @escaping (Expectation) throws -> Void) -> Future<T> {
return map {
try callback($0)
return $0
}
}

public func flatTry(_ callback: @escaping (Expectation) throws -> Future<Void>) -> Future<T> {
func flatTry(_ callback: @escaping (Expectation) throws -> Future<Void>) -> Future<T> {
return flatMap { expectation in
try callback(expectation).map { _ in expectation }
}
}
}

public extension Future where Expectation: OptionalType {
public func `nil`(or error: @autoclosure @escaping () -> Error) -> Future<Void> {
func `nil`(or error: @autoclosure @escaping () -> Error) -> Future<Void> {
return map(to: Void.self) { optional in
guard optional.wrapped == nil else {
throw error()
Expand All @@ -26,7 +26,7 @@ public extension Future where Expectation: OptionalType {
}

public extension Future where Expectation: Equatable {
public func equal(
func equal(
_ expected: Expectation,
or error: @autoclosure @escaping () -> Error
) -> Future<Void> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sugar/Helpers/Leaf/LeafTagConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public extension LeafTagConfig {
/// Register multiple tags using the keys as their names.
///
/// - Parameter list: Map of names to tags.
public mutating func use(_ list: [String: TagRenderer]) {
mutating func use(_ list: [String: TagRenderer]) {
for item in list {
self.use(item.value, as: item.key)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sugar/Helpers/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Fluent
import Vapor

public extension Model {
public static func requireFind(
static func requireFind(
_ id: ID,
on worker: DatabaseConnectable
) -> Future<Self> {
Expand All @@ -11,7 +11,7 @@ public extension Model {
.unwrap(or: Abort(.notFound, reason: "\(Self.self) with id \(id) not found"))
}

public func saveOrUpdate (
func saveOrUpdate (
given filters: [FilterOperator<Self.Database, Self>],
withSoftDeleted: Bool = false,
restore: Bool = false,
Expand Down
8 changes: 4 additions & 4 deletions Sources/Sugar/Helpers/SecondsConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// See https://nshipster.com/timeinterval-date-dateinterval/ for more information.
// Instead these helpers should be used for e.g. setting a expiration time of something.
public extension Numeric {
public var minsInSecs: Self {
var minsInSecs: Self {
return self * 60
}

public var hoursInSecs: Self {
var hoursInSecs: Self {
return self.minsInSecs * 60
}

public var daysInSecs: Self {
var daysInSecs: Self {
return self.hoursInSecs * 24
}

public var weeksInSecs: Self {
var weeksInSecs: Self {
return self.daysInSecs * 7
}
}
2 changes: 1 addition & 1 deletion Sources/Sugar/Helpers/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Crypto
import COperatingSystem

public extension String {
public static func randomAlphaNumericString(_ length: Int = 64) -> String {
static func randomAlphaNumericString(_ length: Int = 64) -> String {
func makeRandom(min: Int, max: Int) -> Int {
let top = max - min + 1
#if os(Linux)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sugar/Helpers/TimeInterval.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public extension Optional where Wrapped == TimeInterval {
public var dateRelativeTo1970: Date? {
var dateRelativeTo1970: Date? {
guard let date = self else {
return nil
}
Expand All @@ -11,7 +11,7 @@ public extension Optional where Wrapped == TimeInterval {
}

public extension TimeInterval {
public var dateRelativeTo1970: Date {
var dateRelativeTo1970: Date {
return Date(timeIntervalSince1970: self)
}
}
4 changes: 2 additions & 2 deletions Sources/Sugar/Helpers/URL.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public extension URL {
public func addQueryItems(_ item: [URLQueryItem]) -> URL {
func addQueryItems(_ item: [URLQueryItem]) -> URL {
guard var components = URLComponents(url: self, resolvingAgainstBaseURL: false) else {
return self
}
Expand All @@ -11,7 +11,7 @@ public extension URL {
return components.url ?? self
}

public func addQueryItems(from url: URL) -> URL {
func addQueryItems(from url: URL) -> URL {
guard
let items = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems
else {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sugar/Validation/StrongPasswordValidator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fileprivate struct StrongPasswordValidator<T>: ValidatorType {
}

fileprivate extension Sequence where Iterator.Element == PasswordRegex {
fileprivate var requirements: String {
var requirements: String {
return self.map { $0.description }.joined(separator: ", ")
}
}

0 comments on commit a1ec33e

Please sign in to comment.