Skip to content

Commit

Permalink
Merge pull request #13 from boostcampwm-2024/feature/set-swiftlint
Browse files Browse the repository at this point in the history
모든 모듈에 SwiftLint 적용
  • Loading branch information
Kyxxn authored Nov 5, 2024
2 parents 0581257 + 47e2466 commit 2f8ba0e
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 13 deletions.
122 changes: 122 additions & 0 deletions MemorialHouse/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# 사용하지 않는 룰
disabled_rules:
# 라인의 마지막에는 빈 여백이 있으면 안 됨 => 라인 마지막에 여백 있어도 됨
- trailing_whitespace

# 타입은 최대 1단계로 중첩되어야 함 => 타입여러개 중첩돼도 됨
- nesting

# 함수 안은 복잡하면 안 됨 (warning: 10, error: 20)
- cyclomatic_complexity

# Protocol은 class-only여야 함.
- class_delegate_protocol

# 함수 매개변수들이 여러 개일 경우 세로로 같은 줄에 있어야 함
- vertical_parameter_alignment

# Void 함수를 호출하기 위해 삼항연산자을 사용하는 것은 피해야 한다.
- void_function_in_ternary

# 스위치 문의 케이스는 스위치와 같은 줄에 있어야 함
- switch_case_alignment

# fileprivate보다 private을 선호함. => fileprivate에 워닝 띄우지 않을꺼다
- private_over_fileprivate

analyzer_rules: # => 적용on
# 모든 선언은 한 번 이상 사용되어야 함
- unused_declaration

# 명시적 룰 활성화
opt_in_rules:
# type name은 영숫자만 포함, 대문자로 시작해 3-40자 사이어야 함
- type_name

# delegate protocol은 class-only로 참조해 weak로 참조되도록 권장
- class_delegate_protocol

# 닫는 괄호 ')'와 '}' 사이에는 공백이 없어야 함
- closing_brace

# 클로저 내용과 괄호 사이에 공백이 있어야 함
- closure_spacing

# collection elem은 vertically aligned 되어야 함
- collection_alignment

# colon 사용 시 앞 공백 필수, 뒷 공백이 있으면 안 됨
- colon

# comma 사용 시 앞 공백 필수, 뒷 공백이 있으면 안 됨
- comma

# first(where:) != nil, firstIndex(where:) != nil 대신 contains 사용을 권장 (https://realm.github.io/SwiftLint/contains_over_first_not_nil.html)
- contains_over_first_not_nil

# filter.count 사용 시 isEmpty 대신 contains 사용 권장 (https://realm.github.io/SwiftLint/contains_over_filter_is_empty.html)
- contains_over_filter_is_empty

# filter.count가 0인지 비교할 때 contains 사용 권장 (https://realm.github.io/SwiftLint/contains_over_filter_count.html)
- contains_over_filter_count

# range(of:) == nil 체크 대신 contains 사용 권장 (https://realm.github.io/SwiftLint/contains_over_range_nil_comparison.html)
- contains_over_range_nil_comparison

# if, for, guard, switch, while, catch 사용 시 () 사용 권장하지 않음
- control_statement

# deployment target 보다 낮은 버전의 @available 사용 시 warning
- deployment_target

# 중복 import 방지
- duplicate_imports

# count가 0인지 체크할 때는 isEmpty 사용 권장
- empty_count

# collection, array count 체크 시 isEmpty 사용 권장
- empty_collection_literal

# string empty 체크 시 isEmpty 사용 권장
- empty_string

# 강제 언래핑 사용 금지
- force_try

# array, dict 사용 시 동일한 indent로 표현
- literal_expression_end_indentation

# let, var 선언 시 다른 statments와 한 줄 공백이 필요함
# - let_var_whitespace # private, let, var 별로 뗄 수도 있으니까

# 수직 공백 2줄 이상 사용 지양
- vertical_whitespace

# 여는 괄호 앞에서 한 줄 이상의 공백 사용 지양
- vertical_whitespace_opening_braces

# 닫는 괄호 앞에서 한 줄 이상의 공백 사용 지양
- vertical_whitespace_closing_braces

# delegate는 약한 참조 사용 권장
- weak_delegate

force_try:
severity: warning # 명시적으로 지정

line_length:
warning: 120
ignores_urls: true
ignores_comments: true

# path
included:
excluded:
- "*.xcodeproj"
- "*.xcworkspace"
- ".git"
- ".gitignore"
- ".github"
- "README.md"
reporter: "xcode"
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 0EE4A0932CD5DD1B00F17FA5 /* Build configuration list for PBXNativeTarget "MemorialHouse" */;
buildPhases = (
CED59DC72CD9E260005BE50D /* Run Script */,
0EE4A07C2CD5DD1800F17FA5 /* Sources */,
0EE4A07D2CD5DD1800F17FA5 /* Frameworks */,
0EE4A07E2CD5DD1800F17FA5 /* Resources */,
Expand All @@ -154,6 +155,7 @@
buildRules = (
);
dependencies = (
CED59DC52CD9E07B005BE50D /* PBXTargetDependency */,
);
name = MemorialHouse;
packageProductDependencies = (
Expand Down Expand Up @@ -186,6 +188,9 @@
);
mainGroup = 0EE4A0772CD5DD1800F17FA5;
minimizedProjectReferenceProxies = 1;
packageReferences = (
CED59DC32CD9E053005BE50D /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 0EE4A0812CD5DD1800F17FA5 /* Products */;
projectDirPath = "";
Expand All @@ -208,6 +213,27 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
CED59DC72CD9E260005BE50D /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Run Script";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "YML=\"../.swiftlint.yml\"\nSWIFT_PACKAGE_DIR=\"${BUILD_DIR%Build/*}SourcePackages/artifacts\"\nSWIFTLINT_CMD=$(ls \"$SWIFT_PACKAGE_DIR\"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*/bin/swiftlint | head -n 1)\n\nif test -f \"$SWIFTLINT_CMD\" 2>&1\nthen\n \"$SWIFTLINT_CMD\" --config ${YML}\nelse\n echo \"warning: `swiftlint` command not found - See https://github.com/realm/SwiftLint#installation for installation instructions.\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
0EE4A07C2CD5DD1800F17FA5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand All @@ -221,6 +247,13 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
CED59DC52CD9E07B005BE50D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = CED59DC42CD9E07B005BE50D /* SwiftLintBuildToolPlugin */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
0EE4A09C2CD5DD2400F17FA5 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
Expand Down Expand Up @@ -336,7 +369,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -399,7 +432,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -440,6 +473,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
CED59DC32CD9E053005BE50D /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins";
requirement = {
kind = exactVersion;
version = 0.57.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
CED59DC42CD9E07B005BE50D /* SwiftLintBuildToolPlugin */ = {
isa = XCSwiftPackageProductDependency;
package = CED59DC32CD9E053005BE50D /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */;
productName = "plugin:SwiftLintBuildToolPlugin";
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 0EE4A0782CD5DD1800F17FA5 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import UIKit

class ViewController: UIViewController {

enum HI {
enum Good {

}
}

override func viewDidLoad() {
super.viewDidLoad()


view.backgroundColor = .red
let numb = [1, 2, 3,
4, 5, 6]
@available(iOS 11.0, *)
func hihi() { }
}
}

37 changes: 37 additions & 0 deletions MemorialHouse/MHCore/MHCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
buildConfigurationList = CE9AEBC12CD7B5EF00F8471D /* Build configuration list for PBXNativeTarget "MHCore" */;
buildPhases = (
CE9AEBB62CD7B5EF00F8471D /* Headers */,
0E7F28852CDA07ED007D4F2B /* ShellScript */,
CE9AEBB72CD7B5EF00F8471D /* Sources */,
CE9AEBB82CD7B5EF00F8471D /* Frameworks */,
CE9AEBB92CD7B5EF00F8471D /* Resources */,
Expand Down Expand Up @@ -119,6 +120,9 @@
);
mainGroup = CE9AEBB12CD7B5EF00F8471D;
minimizedProjectReferenceProxies = 1;
packageReferences = (
0E7F28842CDA07E7007D4F2B /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = CE9AEBBC2CD7B5EF00F8471D /* Products */;
projectDirPath = "";
Expand All @@ -139,6 +143,26 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0E7F28852CDA07ED007D4F2B /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "YML=\"../.swiftlint.yml\"\nSWIFT_PACKAGE_DIR=\"${BUILD_DIR%Build/*}SourcePackages/artifacts\"\nSWIFTLINT_CMD=$(ls \"$SWIFT_PACKAGE_DIR\"/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*/bin/swiftlint | head -n 1)\n\nif test -f \"$SWIFTLINT_CMD\" 2>&1\nthen\n \"$SWIFTLINT_CMD\" --config ${YML}\nelse\n echo \"warning: `swiftlint` command not found - See https://github.com/realm/SwiftLint#installation for installation instructions.\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
CE9AEBB72CD7B5EF00F8471D /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand All @@ -164,6 +188,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -204,6 +229,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -377,6 +403,17 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
0E7F28842CDA07E7007D4F2B /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins";
requirement = {
kind = exactVersion;
version = 0.57.0;
};
};
/* End XCRemoteSwiftPackageReference section */
};
rootObject = CE9AEBB22CD7B5EF00F8471D /* Project object */;
}
1 change: 1 addition & 0 deletions MemorialHouse/MHCore/MHCore/Temp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
//

import Foundation

Loading

0 comments on commit 2f8ba0e

Please sign in to comment.