Fix SwiftLint issues.
This commit is contained in:
parent
e21d9f00c7
commit
deb70b5b99
|
@ -1,8 +1,6 @@
|
|||
disabled_rules:
|
||||
- shorthand_operator
|
||||
- identifier_name
|
||||
- nesting
|
||||
- for_where
|
||||
line_length: 180
|
||||
file_length: 1000
|
||||
type_body_length: 500
|
||||
|
|
|
@ -11,13 +11,13 @@ import Foundation
|
|||
public struct Focus: Codable {
|
||||
|
||||
/// X position int he image.
|
||||
public let x: Int
|
||||
public let xPoint: Int
|
||||
|
||||
/// Y position in the image.
|
||||
public let y: Int
|
||||
public let yPoint: Int
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case x
|
||||
case y
|
||||
case xPoint = "x"
|
||||
case yPoint = "y"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ public struct Thumbnail: Codable {
|
|||
public struct ThumbnailVersions: Codable {
|
||||
|
||||
/// The URL for the thumbnail image at 1x resolution.
|
||||
public let x1: URL?
|
||||
public let resolutionX1: URL?
|
||||
|
||||
/// The URL for the thumbnail image at 2x resolution.
|
||||
public let x2: URL?
|
||||
public let resolutionX2: URL?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case x1 = "@1x"
|
||||
case x2 = "@2x"
|
||||
case resolutionX1 = "@1x"
|
||||
case resolutionX2 = "@2x"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public enum HTTPStatusCode: Int, Error {
|
|||
|
||||
/// - ok: Standard response for successful HTTP requests.
|
||||
case ok = 200
|
||||
// swiftlint:disable:previous identifier_name
|
||||
|
||||
/// - created: The request has been fulfilled, resulting in the creation of a new resource.
|
||||
case created = 201
|
||||
|
|
|
@ -42,12 +42,12 @@ extension Pixelfed.Mutes: TargetType {
|
|||
var page: Page?
|
||||
|
||||
switch self {
|
||||
case .mutes(let _maxId, let _sinceId, let _minId, let _limit, let _page):
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
page = _page
|
||||
case .mutes(let paramMaxId, let paramSinceId, let paramMinId, let paramLimit, let paramPage):
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
page = paramPage
|
||||
}
|
||||
|
||||
if let maxId {
|
||||
|
|
|
@ -49,11 +49,11 @@ extension Pixelfed.Notifications: TargetType {
|
|||
var limit: Limit?
|
||||
|
||||
switch self {
|
||||
case .notifications(let _maxId, let _sinceId, let _minId, let _limit):
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
case .notifications(let paramMaxId, let paramSinceId, let paramMinId, let paramLimit):
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
default: break
|
||||
}
|
||||
|
||||
|
|
|
@ -48,18 +48,26 @@ extension Pixelfed.Search: TargetType {
|
|||
var page: Page?
|
||||
|
||||
switch self {
|
||||
case .search(let _query, let _resultsType, let _resolveNonLocal, let _maxId, let _sinceId, let _minId, let _limit, let _page):
|
||||
case .search(let paramQuery,
|
||||
let paramResultsType,
|
||||
let paramResolveNonLocal,
|
||||
let paramMaxId,
|
||||
let paramSinceId,
|
||||
let paramMinId,
|
||||
let paramLimit,
|
||||
let paramPage):
|
||||
|
||||
params.append(contentsOf: [
|
||||
("q", _query),
|
||||
("type", _resultsType.rawValue),
|
||||
("resolve", _resolveNonLocal.asString)
|
||||
("q", paramQuery),
|
||||
("type", paramResultsType.rawValue),
|
||||
("resolve", paramResolveNonLocal.asString)
|
||||
])
|
||||
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
page = _page
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
page = paramPage
|
||||
}
|
||||
|
||||
if let maxId {
|
||||
|
|
|
@ -177,18 +177,18 @@ extension Pixelfed.Statuses: TargetType {
|
|||
switch self {
|
||||
case .status:
|
||||
pixelfedKey = true
|
||||
case .favouritedBy(_, let _maxId, let _sinceId, let _minId, let _limit, let _page):
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
page = _page
|
||||
case .rebloggedBy(_, let _maxId, let _sinceId, let _minId, let _limit, let _page):
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
page = _page
|
||||
case .favouritedBy(_, let paramMaxId, let paramSinceId, let paramMinId, let paramLimit, let paramPage):
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
page = paramPage
|
||||
case .rebloggedBy(_, let paramMaxId, let paramSinceId, let paramMinId, let paramLimit, let paramPage):
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
page = paramPage
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -49,20 +49,20 @@ extension Pixelfed.Timelines: TargetType {
|
|||
var limit: Limit?
|
||||
|
||||
switch self {
|
||||
case .tag(_, let _local, let _remote, let _onlyMedia, let _maxId, let _sinceId, let _minId, let _limit),
|
||||
.pub(let _local, let _remote, let _onlyMedia, let _maxId, let _sinceId, let _minId, let _limit):
|
||||
local = _local
|
||||
remote = _remote
|
||||
onlyMedia = _onlyMedia
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
case .home(let _maxId, let _sinceId, let _minId, let _limit):
|
||||
maxId = _maxId
|
||||
sinceId = _sinceId
|
||||
minId = _minId
|
||||
limit = _limit
|
||||
case .tag(_, let paramLocal, let paramRemote, let paramOnlyMedia, let paramMaxId, let paramSinceId, let paramMinId, let paramLimit),
|
||||
.pub(let paramLocal, let paramRemote, let paramOnlyMedia, let paramMaxId, let paramSinceId, let paramMinId, let paramLimit):
|
||||
local = paramLocal
|
||||
remote = paramRemote
|
||||
onlyMedia = paramOnlyMedia
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
case .home(let paramMaxId, let paramSinceId, let paramMinId, let paramLimit):
|
||||
maxId = paramMaxId
|
||||
sinceId = paramSinceId
|
||||
minId = paramMinId
|
||||
limit = paramLimit
|
||||
}
|
||||
|
||||
if let maxId {
|
||||
|
|
|
@ -52,18 +52,18 @@ extension Pixelfed.Trends: TargetType {
|
|||
var limit: Limit?
|
||||
|
||||
switch self {
|
||||
case .tags(let _trendRange, let _offset, let _limit):
|
||||
trendRange = _trendRange
|
||||
offset = _offset
|
||||
limit = _limit
|
||||
case .statuses(let _trendRange, let _offset, let _limit):
|
||||
trendRange = _trendRange
|
||||
offset = _offset
|
||||
limit = _limit
|
||||
case .accounts(let _trendRange, let _offset, let _limit):
|
||||
trendRange = _trendRange
|
||||
offset = _offset
|
||||
limit = _limit
|
||||
case .tags(let paramTrendRange, let paramOffset, let paramLimit):
|
||||
trendRange = paramTrendRange
|
||||
offset = paramOffset
|
||||
limit = paramLimit
|
||||
case .statuses(let paramTrendRange, let paramOffset, let paramLimit):
|
||||
trendRange = paramTrendRange
|
||||
offset = paramOffset
|
||||
limit = paramLimit
|
||||
case .accounts(let paramTrendRange, let paramOffset, let paramLimit):
|
||||
trendRange = paramTrendRange
|
||||
offset = paramOffset
|
||||
limit = paramLimit
|
||||
}
|
||||
|
||||
switch trendRange {
|
||||
|
|
|
@ -405,6 +405,8 @@
|
|||
F8B0885F29943498002AB40A /* OtherSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtherSectionView.swift; sourceTree = "<group>"; };
|
||||
F8B08861299435C9002AB40A /* SupportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportView.swift; sourceTree = "<group>"; };
|
||||
F8B1E6502973FB7E00EE0D10 /* ToastrService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastrService.swift; sourceTree = "<group>"; };
|
||||
F8B3699A29D86EB600BE3808 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
|
||||
F8B3699B29D86EBD00BE3808 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
|
||||
F8B9B344298D1FCB009CC69C /* Client.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Client.swift; sourceTree = "<group>"; };
|
||||
F8B9B346298D4A7C009CC69C /* Client+Trends.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+Trends.swift"; sourceTree = "<group>"; };
|
||||
F8B9B348298D4AA2009CC69C /* Client+Timeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+Timeline.swift"; sourceTree = "<group>"; };
|
||||
|
@ -773,6 +775,8 @@
|
|||
F837269429A221420098D3C4 /* PixelfedKit */,
|
||||
F88ABD9529687D4D004EF61E /* README.md */,
|
||||
F844F42429D2DC39000DD896 /* LICENSE */,
|
||||
F8B3699A29D86EB600BE3808 /* .swiftlint.yml */,
|
||||
F8B3699B29D86EBD00BE3808 /* .gitignore */,
|
||||
F8CB3DF029D80B1E00CDAE5A /* Resources */,
|
||||
F835081F29BEF88600DE3247 /* Localization */,
|
||||
F864F79C29BB9D2400B13921 /* Models */,
|
||||
|
|
|
@ -23,12 +23,12 @@ extension UIImage {
|
|||
|
||||
guard blurHash.count == 4 + 2 * numX * numY else { return nil }
|
||||
|
||||
let colours: [(Float, Float, Float)] = (0 ..< numX * numY).map { i in
|
||||
if i == 0 {
|
||||
let colours: [(Float, Float, Float)] = (0 ..< numX * numY).map { index in
|
||||
if index == 0 {
|
||||
let value = String(blurHash[2 ..< 6]).decode83()
|
||||
return decodeDC(value)
|
||||
} else {
|
||||
let value = String(blurHash[4 + i * 2 ..< 4 + i * 2 + 2]).decode83()
|
||||
let value = String(blurHash[4 + index * 2 ..< 4 + index * 2 + 2]).decode83()
|
||||
return decodeAC(value, maximumValue: maximumValue * punch)
|
||||
}
|
||||
}
|
||||
|
@ -40,29 +40,29 @@ extension UIImage {
|
|||
CFDataSetLength(data, bytesPerRow * height)
|
||||
guard let pixels = CFDataGetMutableBytePtr(data) else { return nil }
|
||||
|
||||
for y in 0 ..< height {
|
||||
for x in 0 ..< width {
|
||||
var r: Float = 0
|
||||
var g: Float = 0
|
||||
var b: Float = 0
|
||||
for yPoint in 0 ..< height {
|
||||
for xPoint in 0 ..< width {
|
||||
var red: Float = 0
|
||||
var green: Float = 0
|
||||
var blue: Float = 0
|
||||
|
||||
for j in 0 ..< numY {
|
||||
for i in 0 ..< numX {
|
||||
let basis = cos(Float.pi * Float(x) * Float(i) / Float(width)) * cos(Float.pi * Float(y) * Float(j) / Float(height))
|
||||
let colour = colours[i + j * numX]
|
||||
r += colour.0 * basis
|
||||
g += colour.1 * basis
|
||||
b += colour.2 * basis
|
||||
for jIndex in 0 ..< numY {
|
||||
for iIndex in 0 ..< numX {
|
||||
let basis = cos(Float.pi * Float(xPoint) * Float(iIndex) / Float(width)) * cos(Float.pi * Float(yPoint) * Float(jIndex) / Float(height))
|
||||
let colour = colours[iIndex + jIndex * numX]
|
||||
red += colour.0 * basis
|
||||
green += colour.1 * basis
|
||||
blue += colour.2 * basis
|
||||
}
|
||||
}
|
||||
|
||||
let intR = UInt8(linearTosRGB(r))
|
||||
let intG = UInt8(linearTosRGB(g))
|
||||
let intB = UInt8(linearTosRGB(b))
|
||||
let intR = UInt8(linearTosRGB(red))
|
||||
let intG = UInt8(linearTosRGB(green))
|
||||
let intB = UInt8(linearTosRGB(blue))
|
||||
|
||||
pixels[3 * x + 0 + y * bytesPerRow] = intR
|
||||
pixels[3 * x + 1 + y * bytesPerRow] = intG
|
||||
pixels[3 * x + 2 + y * bytesPerRow] = intB
|
||||
pixels[3 * xPoint + 0 + yPoint * bytesPerRow] = intR
|
||||
pixels[3 * xPoint + 1 + yPoint * bytesPerRow] = intG
|
||||
pixels[3 * xPoint + 2 + yPoint * bytesPerRow] = intB
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ private func signPow(_ value: Float, _ exp: Float) -> Float {
|
|||
}
|
||||
|
||||
private func linearTosRGB(_ value: Float) -> Int {
|
||||
let v = max(0, min(1, value))
|
||||
if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) } else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }
|
||||
let maxV = max(0, min(1, value))
|
||||
if maxV <= 0.0031308 { return Int(maxV * 12.92 * 255 + 0.5) } else { return Int((1.055 * pow(maxV, 1 / 2.4) - 0.055) * 255 + 0.5) }
|
||||
}
|
||||
|
||||
private func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {
|
||||
let v = Float(Int64(value)) / 255
|
||||
if v <= 0.04045 { return v / 12.92 } else { return pow((v + 0.055) / 1.055, 2.4) }
|
||||
let floatV = Float(Int64(value)) / 255
|
||||
if floatV <= 0.04045 { return floatV / 12.92 } else { return pow((floatV + 0.055) / 1.055, 2.4) }
|
||||
}
|
||||
|
||||
private let encodeCharacters: [String] = {
|
||||
|
|
|
@ -143,10 +143,8 @@ public class HomeTimelineService {
|
|||
|
||||
// Remove statuses that are not in 40 downloaded once.
|
||||
var dbStatusesToRemove: [StatusData] = []
|
||||
for dbStatus in dbStatuses {
|
||||
if !statuses.contains(where: { status in status.id == dbStatus.id }) {
|
||||
dbStatusesToRemove.append(dbStatus)
|
||||
}
|
||||
for dbStatus in dbStatuses where !statuses.contains(where: { status in status.id == dbStatus.id }) {
|
||||
dbStatusesToRemove.append(dbStatus)
|
||||
}
|
||||
|
||||
if !dbStatusesToRemove.isEmpty {
|
||||
|
@ -155,10 +153,8 @@ public class HomeTimelineService {
|
|||
|
||||
// Add statuses which are not existing in database, but has been downloaded via API.
|
||||
var statusesToAdd: [Status] = []
|
||||
for status in statuses {
|
||||
if !dbStatuses.contains(where: { statusData in statusData.id == status.id }) {
|
||||
statusesToAdd.append(status)
|
||||
}
|
||||
for status in statuses where !dbStatuses.contains(where: { statusData in statusData.id == status.id }) {
|
||||
statusesToAdd.append(status)
|
||||
}
|
||||
|
||||
// Save statuses in database.
|
||||
|
|
|
@ -55,6 +55,7 @@ class RouterPath: ObservableObject {
|
|||
|
||||
public init() {}
|
||||
|
||||
// swiftlint:disable:next identifier_name
|
||||
public func navigate(to: RouteurDestinations) {
|
||||
path.append(to)
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ struct ImagesGrid: View {
|
|||
|
||||
// Clear placeholders when there is small number of photos.
|
||||
if index < self.maxImages {
|
||||
for i in (index...self.maxImages - 1).reversed() {
|
||||
self.photoUrls.remove(at: i)
|
||||
for position in (index...self.maxImages - 1).reversed() {
|
||||
self.photoUrls.remove(at: position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue