Skip to content

Commit

Permalink
Refactored files for lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vcosmin2701 committed Jan 1, 2025
1 parent 4adbe2e commit 99878d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
16 changes: 8 additions & 8 deletions DesignPatterns/Factory/factory-practice-2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ protocol Character {
func attack()
func defend()

var HP: Int { get }
var MP: Int { get }
var weaponType: String { get }
var armorType: String { get }
var HP:Int { get }

Check warning on line 7 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)

Check warning on line 7 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Identifier Name Violation: Variable name 'HP' should be between 3 and 40 characters long (identifier_name)
var MP:Int { get }

Check warning on line 8 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)

Check warning on line 8 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Identifier Name Violation: Variable name 'MP' should be between 3 and 40 characters long (identifier_name)
var weaponType:String { get }

Check warning on line 9 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
var armorType:String { get }

Check warning on line 10 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
}

enum CharacterType {
Expand All @@ -30,19 +30,19 @@ class Warrior: Character {
print("Warrior is defending.")
}

var HP: Int {
var HP:Int {

Check warning on line 33 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
return 100
}

var MP: Int {
var MP:Int {

Check warning on line 37 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
return 57
}

var weaponType: String {
var weaponType:String {

Check warning on line 41 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
return "Sword"
}

var armorType: String {
var armorType:String {

Check warning on line 45 in DesignPatterns/Factory/factory-practice-2.swift

View workflow job for this annotation

GitHub Actions / lint

Colon Spacing Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
return "Strong"
}
}
Expand Down
37 changes: 19 additions & 18 deletions test.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
struct userAccount{
var userName:String
var userAge:Int
var isActive : Bool

func printUserDetails(){print("\(userName) is \(userAge) years old")
if(isActive==true){
struct userAccount {

Check failure on line 1 in test.swift

View workflow job for this annotation

GitHub Actions / lint

Type Name Violation: Type name 'userAccount' should start with an uppercase character (type_name)
var userName: String
var userAge: Int
var isActive: Bool

func printUserDetails() {
print("\(userName) is \(userAge) years old")
if isActive == true {
print("Account is active")
}
else {
} else {
print("Account is inactive")
}
}

func calculateDiscount()->Double{
var discount:Double = 0.0
if userAge>60{discount=0.2}
else if(userAge>30){

func calculateDiscount() -> Double {
var discount: Double = 0.0
if userAge > 60 {
discount = 0.2
} else if userAge > 30 {
discount = 0.1
}
return discount
}
return discount
}}
}

let newUser=userAccount(userName: "john",userAge:25,isActive:true)
let newUser = userAccount(userName: "john", userAge: 25, isActive: true)
newUser.printUserDetails()

0 comments on commit 99878d9

Please sign in to comment.