diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..4338c906 --- /dev/null +++ b/.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 diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 00000000..5310eee9 --- /dev/null +++ b/.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 diff --git a/assets/.DS_Store b/assets/.DS_Store deleted file mode 100644 index 1ff8a090..00000000 Binary files a/assets/.DS_Store and /dev/null differ diff --git a/star-dash/.DS_Store b/star-dash/.DS_Store deleted file mode 100644 index 447b662d..00000000 Binary files a/star-dash/.DS_Store and /dev/null differ diff --git a/star-dash/star-dash.xcodeproj/project.xcworkspace/xcuserdata/proglab.xcuserdatad/UserInterfaceState.xcuserstate b/star-dash/star-dash.xcodeproj/project.xcworkspace/xcuserdata/proglab.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index b942bb0a..00000000 Binary files a/star-dash/star-dash.xcodeproj/project.xcworkspace/xcuserdata/proglab.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/star-dash/star-dash/.DS_Store b/star-dash/star-dash/.DS_Store deleted file mode 100644 index fda27587..00000000 Binary files a/star-dash/star-dash/.DS_Store and /dev/null differ diff --git a/star-dash/star-dash/AppDelegate.swift b/star-dash/star-dash/AppDelegate.swift index 2dfa4d9b..e7c60c09 100644 --- a/star-dash/star-dash/AppDelegate.swift +++ b/star-dash/star-dash/AppDelegate.swift @@ -32,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { // 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. } diff --git a/star-dash/star-dash/Entities/Components/SpriteComponent.swift b/star-dash/star-dash/Entities/Components/SpriteComponent.swift index f9733f4f..7d26ac7f 100644 --- a/star-dash/star-dash/Entities/Components/SpriteComponent.swift +++ b/star-dash/star-dash/Entities/Components/SpriteComponent.swift @@ -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 diff --git a/star-dash/star-dash/Entities/Entity.swift b/star-dash/star-dash/Entities/Entity.swift index 75d7cb12..2124ea02 100644 --- a/star-dash/star-dash/Entities/Entity.swift +++ b/star-dash/star-dash/Entities/Entity.swift @@ -10,7 +10,7 @@ import Foundation typealias EntityId = UUID protocol Entity { - var id: EntityId {get} + var id: EntityId { get } func setUpAndAdd(to: EntityManager) } diff --git a/star-dash/star-dash/Rendering/MTKRenderer/MTKRenderer.swift b/star-dash/star-dash/Rendering/MTKRenderer/MTKRenderer.swift index 72d08d63..ecad5fcc 100644 --- a/star-dash/star-dash/Rendering/MTKRenderer/MTKRenderer.swift +++ b/star-dash/star-dash/Rendering/MTKRenderer/MTKRenderer.swift @@ -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()) diff --git a/star-dash/star-dash/SceneDelegate.swift b/star-dash/star-dash/SceneDelegate.swift index 1c701e8b..12600b00 100644 --- a/star-dash/star-dash/SceneDelegate.swift +++ b/star-dash/star-dash/SceneDelegate.swift @@ -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). } diff --git a/star-dash/star-dashTests/star_dashTests.swift b/star-dash/star-dashTests/star_dashTests.swift index d03ea1c2..6a746c07 100644 --- a/star-dash/star-dashTests/star_dashTests.swift +++ b/star-dash/star-dashTests/star_dashTests.swift @@ -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. + // } + // } } diff --git a/star-dash/star-dashUITests/star_dashUITests.swift b/star-dash/star-dashUITests/star_dashUITests.swift index 44bbcb08..48efc1a4 100644 --- a/star-dash/star-dashUITests/star_dashUITests.swift +++ b/star-dash/star-dashUITests/star_dashUITests.swift @@ -15,28 +15,28 @@ final class star_dashUITests: XCTestCase { // 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() + // } + // } + // } } diff --git a/star-dash/star-dashUITests/star_dashUITestsLaunchTests.swift b/star-dash/star-dashUITests/star_dashUITestsLaunchTests.swift index bcb81d27..cb745585 100644 --- a/star-dash/star-dashUITests/star_dashUITestsLaunchTests.swift +++ b/star-dash/star-dashUITests/star_dashUITestsLaunchTests.swift @@ -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) + // } }