Skip to content

Commit c709a61

Browse files
Add CodeQL analysis workflow, SwiftLint configuration, and update README and CHANGELOG
- Introduced CodeQL workflow for security analysis. - Configured SwiftLint for code linting in Sources and Tests. - Updated README to reflect CI badge change and usage instructions. - Added documentation for ShitLib library. - Updated CHANGELOG for version 6.0.0 with relevant changes.
1 parent 885efcb commit c709a61

File tree

7 files changed

+202
-35
lines changed

7 files changed

+202
-35
lines changed

.github/workflows/codeql.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "main", "develop" ]
17+
pull_request:
18+
branches: [ "main", "develop" ]
19+
schedule:
20+
- cron: '20 5 * * 4'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: macos-latest
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: actions
47+
build-mode: none
48+
- language: swift
49+
build-mode: manual
50+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
51+
# Use `c-cpp` to analyze code written in C, C++ or both
52+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
53+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
54+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
55+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
56+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
57+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v5
61+
62+
# Add any setup steps before running the `github/codeql-action/init` action.
63+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
64+
# or others). This is typically only required for manual builds.
65+
# - name: Setup runtime (example)
66+
# uses: actions/setup-example@v1
67+
68+
# Initializes the CodeQL tools for scanning.
69+
- name: Initialize CodeQL
70+
uses: github/codeql-action/init@v3
71+
with:
72+
languages: ${{ matrix.language }}
73+
build-mode: ${{ matrix.build-mode }}
74+
tools: linked
75+
# If you wish to specify custom queries, you can do so here or in a config file.
76+
# By default, queries listed here will override any specified in a config file.
77+
# Prefix the list here with "+" to use these queries and those in the config file.
78+
79+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
80+
# queries: security-extended,security-and-quality
81+
82+
# If the analyze step fails for one of the languages you are analyzing with
83+
# "We were unable to automatically build your code", modify the matrix above
84+
# to set the build mode to "manual" for that language. Then modify this step
85+
# to build your code.
86+
# ℹ️ Command-line programs to run using the OS shell.
87+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
88+
- if: matrix.build-mode == 'manual'
89+
run: swift build -v
90+
91+
- name: Perform CodeQL Analysis
92+
uses: github/codeql-action/analyze@v3
93+
with:
94+
category: "/language:${{matrix.language}}"

.github/workflows/swift.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
name: Swift
1+
name: Swift CI
22

33
on:
44
push:
55
branches: [ main, develop ]
66
pull_request:
77
branches: [ main, develop ]
88

9-
jobs:
10-
build:
9+
permissions:
10+
contents: read
1111

12+
jobs:
13+
test-and-coverage:
14+
name: Test and Coverage
1215
runs-on: macos-latest
13-
1416
steps:
1517
- uses: actions/checkout@v5
16-
- name: Build
17-
run: swift build -v
18+
- uses: maxim-lobanov/setup-xcode@v1
19+
with:
20+
xcode-version: '26.0-beta'
1821
- name: Run tests
1922
run: swift test -v --enable-code-coverage
2023
- name: Export coverage report as Lcov
21-
run: xcrun llvm-cov export -format="lcov" -instr-profile=.build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/ShitLibPackageTests.xctest/Contents/MacOS/ShitLibPackageTests > lcov.info
24+
run: xcrun llvm-cov export -format="lcov" -instr-profile=.build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/ArachnePackageTests.xctest/Contents/MacOS/ArachnePackageTests > lcov.info
2225
- uses: codecov/codecov-action@v5
2326
with:
27+
token: ${{ secrets.CODECOV_TOKEN }}
2428
files: lcov.info

.github/workflows/swiftlint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: SwiftLint
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
swiftlint:
14+
name: SwiftLint
15+
runs-on: macos-latest
16+
steps:
17+
- uses: actions/checkout@v5
18+
- name: Install SwiftLint
19+
run: brew install swiftlint
20+
- name: Lint Sources
21+
run: swiftlint lint --strict --working-directory Sources
22+
- name: Lint Tests
23+
run: swiftlint lint --strict --working-directory Tests

.spi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [ShitLib]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [6.0.0] - 2025-09-11
8+
### Changed
9+
- osNull wrapped value must conform to Sendable to comply with Swift 6 rules.
10+
711
## [5.0.0] - 2022-02-27
812
### Changed
913
- Use standard Swift Package structure to be more lightweight and more Xcode syntax coloring and autocomplete friendly.
@@ -36,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3640
- Tests with 100% coverage
3741
- Added support for CocoaPods
3842

43+
[6.0.0]: https://github.com/ShitLib/shitlib-swift/compare/5.0.0...6.0.0
44+
[5.0.0]: https://github.com/ShitLib/shitlib-swift/compare/4.0.0...5.0.0
3945
[4.0.0]: https://github.com/ShitLib/shitlib-swift/compare/3.1.0...4.0.0
4046
[3.1.0]: https://github.com/ShitLib/shitlib-swift/compare/3.0.0...3.1.0
4147
[3.0.0]: https://github.com/ShitLib/shitlib-swift/compare/2.0.0...3.0.0

README.md

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ShitLib (oh Shit!)
22

3-
[![Swift](https://github.com/ShitLib/shitlib-swift/actions/workflows/swift.yml/badge.svg)](https://github.com/ShitLib/shitlib-swift/actions/workflows/swift.yml)
3+
[![Swift CI](https://github.com/ShitLib/shitlib-swift/actions/workflows/swift.yml/badge.svg)](https://github.com/ShitLib/shitlib-swift/actions/workflows/swift.yml?branch=main)
44
[![codecov](https://codecov.io/gh/ShitLib/shitlib-swift/branch/main/graph/badge.svg?token=WqSvdoVifd)](https://codecov.io/gh/ShitLib/shitlib-swift)
55
[![Join the chat at https://gitter.im/ShitLib/shitlib-swift](https://badges.gitter.im/ShitLib/shitlib-swift.svg)](https://gitter.im/ShitLib/shitlib-swift?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
66

@@ -65,39 +65,19 @@ class MyBeautifulUnconfigurableClass {
6565

6666
### Swift Package Manager
6767

68-
ShitLib is compatible with [Swift Package Manager](https://swift.org/package-manager). To use it, add the following as a dependency to your `Package.swift` file:
68+
#### Using Xcode UI
6969

70-
```swift
71-
.package(url: "https://github.com/ShitLib/shitlib-swift.git", .upToNextMajor(from: "5.0.0"))
72-
```
73-
74-
### Other package managers
75-
76-
Since version 5.0.0, support for CocoaPods and Carthage has been discontinued, if you need to use them for any reason, you can use version 4.0.0, since the API isn't changed.
77-
78-
<details><summary>CocoaPods</summary>
79-
<p>
70+
Go to your Project Settings > Swift Packages and add Arachne by entering `https://github.com/ShitLib/shitlib-swift.git` in the search field.
8071

81-
ShitLib till version 4.0.0 is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your `Podfile`:
72+
#### Not using Xcode UI
8273

83-
```ruby
84-
pod 'ShitLib', '~> 4.0'
85-
```
86-
87-
</p>
88-
</details>
89-
90-
<details><summary>Carthage</summary>
91-
<p>
74+
Add the following as a dependency to your `Package.swift`:
9275

93-
ShitLib till version 4.0.0 is compatible with [Carthage](https://github.com/Carthage/Carthage). To use it, add the following line to your `Cartfile`:
94-
95-
```ruby
96-
github "ShitLib/shitlib-swift" ~> 4.0.0
76+
```swift
77+
.package(url: "https://github.com/ShitLib/shitlib-swift.git", .upToNextMajor(from: "6.0.0"))
9778
```
9879

99-
</p>
100-
</details>
80+
and then specify "ShitLib" as a dependency of the Target in which you wish to use it.
10181

10282
## What's new
10383

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ``ShitLib``
2+
3+
The library that helps you remember about things done bad.
4+
With ShitLib you will be always aware of the shitty code inside your application.
5+
6+
## Overview
7+
8+
Are you writing unwanted code, antipatterns, magic numbers?
9+
Are you scared about what you are doing?
10+
Use ShitLib to refer your shitty code so you will remember it.
11+
How? Remove ShitLib dependency and your code will not compile anymore until you will remove all of the shitty code.
12+
13+
14+
Oh your boss forced you to get the first element of a list and you know that it's wrong: you can use OhShit!
15+
16+
```swift
17+
import ShitLib
18+
19+
class MyBeautifulClass {
20+
let elements: [String] = [**some elements inside**]
21+
22+
func iDontWantToDoThisButWeMustReleaseASAP() {
23+
let element = elements[OhShit.os0] // <--- OhShit Constant
24+
doSomeThing(with: element)
25+
}
26+
27+
func doSomeThing(with element: String) {
28+
// anything
29+
}
30+
}
31+
```
32+
33+
Maybe you are thinking where the convenience is in using this lib.
34+
It's simple, this is the most useful library when it is removed from dependencies.
35+
After doing that, your project will not compile anymore and you will be immediately aware of what to do.
36+
Fix it!
37+
38+
Other ways to use ShitLib? Let's give a try to the method API
39+
40+
```swift
41+
import ShitLib
42+
43+
class MyBeautifulUnconfigurableClass {
44+
enum PasswordError: Error {
45+
case length(maxLength: Int)
46+
}
47+
48+
let maxPasswordSize: Int = OhShit.ohShit(7)! // I cannot parameterize now
49+
50+
public func set(password: String) throws {
51+
if password.count > maxPasswordSize {
52+
throw PasswordError.length(maxLength: maxPasswordSize)
53+
}
54+
}
55+
}
56+
```

0 commit comments

Comments
 (0)