ShitLib (哦,糟糕!)

Swift Quality Gate Status codecov Join the chat at https://gitter.im/ShitLib/shitlib-swift

你唯一希望移除的库!

这个库帮助你记住那些糟糕的事情。有了 ShitLib,你将始终意识到应用程序中的糟糕代码。

用法

你是否正在编写不需要的代码、反模式、魔法数字? 你是否对你正在做的事情感到害怕? 使用 ShitLib 来标记你的糟糕代码,这样你就会记住它。 怎么做? 移除 ShitLib 依赖,你的代码将无法编译,直到你删除所有糟糕的代码。

哦,你的老板强迫你获取列表的第一个元素,你知道这是错误的:你可以使用 OhShit!

import ShitLib

class MyBeautifulClass {
    let elements: [String] = [**some elements inside**]

    func iDontWantToDoThisButWeMustReleaseASAP() {
        let element = elements[OhShit.os0] // <--- OhShit Constant
        doSomeThing(with: element)
    }

    func doSomeThing(with element: String) {
        // anything
    }
}

也许你正在思考使用这个库的便利之处在哪里。 这很简单,这是从依赖项中移除后最有用的库。 完成之后,你的项目将不再编译,你将立即知道该怎么做。 修复它!

使用 ShitLib 的其他方法? 让我们尝试一下方法 API

import ShitLib

class MyBeautifulUnconfigurableClass {
    enum PasswordError: Error {
        case length(maxLength: Int)
    }

    let maxPasswordSize: Int = OhShit.ohShit(7)! // I cannot parameterize now

    public func set(password: String) throws {
        if password.count > maxPasswordSize {
            throw PasswordError.length(maxLength: maxPasswordSize)
        }
    }
}

安装

Swift 包管理器

ShitLib 兼容 Swift Package Manager。 要使用它,请将以下内容作为依赖项添加到你的 Package.swift 文件中

.package(url: "https://github.com/ShitLib/shitlib-swift.git", .upToNextMajor(from: "5.0.0"))

其他包管理器

自 5.0.0 版本起,已停止支持 CocoaPods 和 Carthage。 如果出于任何原因需要使用它们,可以使用 4.0.0 版本,因为 API 没有更改。

CocoaPods

直到 4.0.0 版本的 ShitLib 都可以通过 CocoaPods 获得。 要安装它,只需将以下行添加到你的 Podfile

pod 'ShitLib', '~> 4.0'

Carthage

直到 4.0.0 版本的 ShitLib 兼容 Carthage。 要使用它,请将以下行添加到你的 Cartfile

github "ShitLib/shitlib-swift" ~> 4.0.0

最新更新

查看我们的 更新日志

许可证

本项目根据 MIT 许可证 发布。