Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter workflow #5

Merged
merged 13 commits into from Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/linter.yml
@@ -0,0 +1,23 @@
name: linter

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/realm/swiftlint:5.5-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Check swiftlint version
run: swiftlint version

- name: Run SwiftLint
run: swiftlint --reporter github-actions-logging --strict
83 changes: 83 additions & 0 deletions .swiftlint.yml
@@ -0,0 +1,83 @@
excluded:
- Pods

opt_in_rules:
- anyobject_protocol
- array_init
- attributes
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- conditional_returns_on_newline
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- empty_collection_literal
- empty_count
- empty_string
- empty_xctest_method
- expiring_todo
- explicit_init
- explicit_self
- fallthrough
- fatal_error_message
- file_name
- first_where
- flatmap_over_map_reduce
- function_default_parameter_at_end
- identical_operands
- implicit_return
- joined_default_parameter
- last_where
- legacy_multiple
- legacy_random
- lower_acl_than_parent
- modifier_order
- nimble_operator
- no_extension_access_modifier
- nslocalizedstring_key
- nslocalizedstring_require_bundle
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- private_action
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- required_enum_case
- single_test_class
- sorted_first_last
- static_operator
- strong_iboutlet
- switch_case_on_newline
- toggle_bool
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- unused_declaration
- unused_import
- vertical_parameter_alignment_on_call
- xct_specific_matcher
- yoda_condition

disabled_rules:
- attributes
- identifier_name
- multiple_closures_with_trailing_closure # for e.g. SwiftUI buttons
- todo
- type_name

line_length:
warning: 120
error: 150
Binary file removed assets/.DS_Store
Binary file not shown.
Binary file removed star-dash/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file removed star-dash/star-dash/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion star-dash/star-dash/AppDelegate.swift
Expand Up @@ -32,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly
// If any sessions were discarded while the application was not running, this will be called shortly
// after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
Expand Down
Expand Up @@ -8,7 +8,7 @@
import Foundation

class SpriteComponent: Component {
// TODO: sprite could be single image or sprite set, could use enum to seperate,
// TODO: sprite could be single image or sprite set, could use enum to seperate,
// for sprite set will need to discuss how to rep animation
var image: String
var size: CGSize
Expand Down
2 changes: 1 addition & 1 deletion star-dash/star-dash/Entities/Entity.swift
Expand Up @@ -10,7 +10,7 @@ import Foundation
typealias EntityId = UUID

protocol Entity {
var id: EntityId {get}
var id: EntityId { get }

func setUpAndAdd(to: EntityManager)
}
4 changes: 2 additions & 2 deletions star-dash/star-dash/Rendering/MTKRenderer/MTKRenderer.swift
Expand Up @@ -48,8 +48,8 @@ extension MTKRenderer: MTKViewDelegate {

func draw(in view: MTKView) {
guard let renderPassDescriptor = view.currentRenderPassDescriptor,
let commandBuffer = commandQueue.makeCommandBuffer(),
let drawable = view.currentDrawable else {
let commandBuffer = commandQueue.makeCommandBuffer(),
let drawable = view.currentDrawable else {
return
}
renderer.update(atTime: CACurrentMediaTime())
Expand Down
2 changes: 1 addition & 1 deletion star-dash/star-dash/SceneDelegate.swift
Expand Up @@ -30,7 +30,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded
// The scene may re-connect later, as its session was not necessarily discarded
// (see `application:didDiscardSceneSessions` instead).
}

Expand Down
40 changes: 20 additions & 20 deletions star-dash/star-dashTests/star_dashTests.swift
Expand Up @@ -10,28 +10,28 @@ import XCTest

final class star_dashTests: XCTestCase {

// override func setUpWithError() throws {
// // Put setup code here. This method is called before the invocation of each test method in the class.
// }
// override func setUpWithError() throws {
// // Put setup code here. This method is called before the invocation of each test method in the class.
// }

// override func tearDownWithError() throws {
// // Put teardown code here. This method is called after the invocation of each test method in the class.
// }
// override func tearDownWithError() throws {
// // Put teardown code here. This method is called after the invocation of each test method in the class.
// }

// func testExample() throws {
// // This is an example of a functional test case.
// // Use XCTAssert and related functions to verify your tests produce the correct results.
// // Any test you write for XCTest can be annotated as throws and async.
// // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with
// // assertions afterwards.
// }
// func testExample() throws {
// // This is an example of a functional test case.
// // Use XCTAssert and related functions to verify your tests produce the correct results.
// // Any test you write for XCTest can be annotated as throws and async.
// // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with
// // assertions afterwards.
// }

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
// func testPerformanceExample() throws {
// // This is an example of a performance test case.
// self.measure {
// // Put the code you want to measure the time of here.
// }
// }

}
42 changes: 21 additions & 21 deletions star-dash/star-dashUITests/star_dashUITests.swift
Expand Up @@ -9,34 +9,34 @@

final class star_dashUITests: XCTestCase {

override func setUpWithError() throws {

Check failure on line 12 in star-dash/star-dashUITests/star_dashUITests.swift

View workflow job for this annotation

GitHub Actions / build

Empty XCTest method should be avoided. (empty_xctest_method)

Check failure on line 12 in star-dash/star-dashUITests/star_dashUITests.swift

View workflow job for this annotation

GitHub Actions / build

Method 'setUpWithError()' should call to super function (overridden_super_call)
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation -
// In UI tests it’s important to set the initial state - such as interface orientation -
// required for your tests before they run. The setUp method is a good place to do this.
}

// override func tearDownWithError() throws {
// // Put teardown code here. This method is called after the invocation of each test method in the class.
// }

func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
// override func tearDownWithError() throws {
// // Put teardown code here. This method is called after the invocation of each test method in the class.
// }

// func testExample() throws {
// // UI tests must launch the application that they test.
// let app = XCUIApplication()
// app.launch()

// // Use XCTAssert and related functions to verify your tests produce the correct results.
// }

// func testLaunchPerformance() throws {
// if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// // This measures how long it takes to launch your application.
// measure(metrics: [XCTApplicationLaunchMetric()]) {
// XCUIApplication().launch()
// }
// }
// }
}
32 changes: 16 additions & 16 deletions star-dash/star-dashUITests/star_dashUITestsLaunchTests.swift
Expand Up @@ -9,24 +9,24 @@ import XCTest

final class star_dashUITestsLaunchTests: XCTestCase {

override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
// override class var runsForEachTargetApplicationUIConfiguration: Bool {
// true
// }

override func setUpWithError() throws {
continueAfterFailure = false
}
// override func setUpWithError() throws {
// continueAfterFailure = false
// }

func testLaunch() throws {
let app = XCUIApplication()
app.launch()
// func testLaunch() throws {
// let app = XCUIApplication()
// app.launch()

// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app
// // Insert steps here to perform after app launch but before taking a screenshot,
// // such as logging into a test account or navigating somewhere in the app

let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
// let attachment = XCTAttachment(screenshot: app.screenshot())
// attachment.name = "Launch Screen"
// attachment.lifetime = .keepAlways
// add(attachment)
// }
}