Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/reformat-code'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Sep 18, 2023
2 parents 19ea4f7 + cc5c5a7 commit 54e4e86
Show file tree
Hide file tree
Showing 44 changed files with 154 additions and 146 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-linter-swift-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
echo ""
echo "🏃‍♂️ Running swift-format on modified files 🤵‍♂️"
swift-format --version
git diff --name-status origin/main \
| grep -E "^A|^M" | sed "s/^[AM]\t//g" \
| grep -E "\.swift\$$" \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-linter-swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
echo ""
echo "🏃‍♂️ Running swiftlint on modified files 🤵‍♂️"
swiftlint --version
git diff --name-status origin/main \
| grep -E "^A|^M" | sed "s/^[AM]\t//g" \
| grep -E "\.swift\$$" \
Expand Down
113 changes: 58 additions & 55 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -1,56 +1,59 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentation": {
"spaces": 4
},
"indentConditionalCompilationBlocks": true,
"indentSwitchCaseLabels": true,
"lineBreakAroundMultilineExpressionChainComponents": true,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineLength": 120,
"maximumBlankLines": 1,
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoVoidReturnOnFunctionSignature": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"UseEarlyExits": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": false
},
"tabWidth": 4,
"version": 1
}
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentation": {
"spaces": 4
},
"indentConditionalCompilationBlocks": true,
"indentSwitchCaseLabels": true,
"lineBreakAroundMultilineExpressionChainComponents": true,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineLength": 120,
"maximumBlankLines": 1,
"multiElementCollectionTrailingCommas": true,
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": true,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"UseEarlyExits": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": false
},
"tabWidth": 4,
"version": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ExplorerActivity: ObservableObject {
}

func makeActivity() -> Activity {
return Activity(
Activity(
id: UUID(),
title: emptyTitle,
short: emptyShort,
Expand All @@ -39,14 +39,14 @@ class ExplorerActivity: ObservableObject {
)

func emptyInstructions() -> LocalizedContent {
return LocalizedContent(
LocalizedContent(
enUS: String.markdownInstructionsEN,
frFR: String.markdownInstructionsFR)
}

// swiftlint:disable trailing_comma
func makeEmptyStepArray() -> [[Step]] {
return [
[
Array(
repeating: Step(
interface: interface,
Expand Down Expand Up @@ -165,7 +165,7 @@ class ExplorerActivity: ObservableObject {
var melodyAnswers = ["pink", "red", "orange", "yellow", "green", "blue", "purple"]

func stepInstruction() -> LocalizedContent {
return LocalizedContent(
LocalizedContent(
enUS: stepInstructions,
frFR: stepInstructions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SwiftUI
struct Activity: Codable, Equatable, Identifiable {

static func == (lhs: Activity, rhs: Activity) -> Bool {
return lhs.id == rhs.id
lhs.id == rhs.id
}

enum CodingKeys: String, CodingKey {
Expand Down Expand Up @@ -57,7 +57,7 @@ struct Activity: Codable, Equatable, Identifiable {
// Step conforms to Equatable because steps are compared when randomized
struct Step: Codable, Equatable, Identifiable {
static func == (lhs: Step, rhs: Step) -> Bool {
return lhs.instruction == rhs.instruction
lhs.instruction == rhs.instruction
}

enum CodingKeys: String, CodingKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ protocol DragAndDropSceneProtocol: SKScene {

extension DragAndDropSceneProtocol {

var biggerSide: CGFloat { return 130 }
var dropAreas: [SKSpriteNode] { return [] }
var biggerSide: CGFloat { 130 }
var dropAreas: [SKSpriteNode] { [] }

@MainActor func makeAnswers() {
for choice in gameEngine!.allAnswers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AssociationFour: SKScene, DragAndDropSceneProtocol {
var biggerSide: CGFloat = 150
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]

// internals
private var initialNodeX: CGFloat = .zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AssociationSix: SKScene, DragAndDropSceneProtocol {
var biggerSide: CGFloat = 150
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]

// internals
private var initialNodeX: CGFloat = .zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BasketFourScene: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// internal properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BasketOneScene: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// protocol methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BasketTwoScene: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// protocol methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EmptyBasketScene: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// internal properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropAreaOneAssetOne: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// protocol methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropAreaOneAssetsThree: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// protocol methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropAreaTwoAssetOne: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// protocol methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropAreaTwoAssetsSix: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// internals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropAreaTwoAssetsTwo: SKScene, DragAndDropSceneProtocol {
var spacer: CGFloat = .zero
var defaultPosition = CGPoint.zero
var selectedNodes: [UITouch: DraggableItemNode] = [:]
var expectedItemsNodes = [String: [SKSpriteNode]]()
var expectedItemsNodes: [String: [SKSpriteNode]] = [:]
var dropAreas: [SKSpriteNode] = []

// protocol methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import SwiftUI

extension SKSpriteNode {
func fullyContains(bounds: CGRect) -> Bool {
return (self.position.x - (self.size.width / 2) >= bounds.minX)
(self.position.x - (self.size.width / 2) >= bounds.minX)
&& (self.position.y - (self.size.height / 2) >= bounds.minY)
&& (self.position.x + (self.size.width / 2) <= bounds.maxX)
&& (self.position.y + (self.size.height / 2) <= bounds.maxY)
}
func fullyContains(location: CGPoint, bounds: CGRect) -> Bool {
return (location.x - (self.size.width / 3) >= bounds.minX)
(location.x - (self.size.width / 3) >= bounds.minX)
&& (location.y - (self.size.height / 3) >= bounds.minY)
&& (location.x + (self.size.width / 3) <= bounds.maxX)
&& (location.y + (self.size.height / 3) <= bounds.maxY)
Expand Down
Loading

0 comments on commit 54e4e86

Please sign in to comment.