diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index c1a553b..9e9063a 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -17,14 +17,6 @@ defaults: working-directory: OpenHaystack jobs: - lint-swift: - runs-on: macos-latest - steps: - - name: "Checkout code" - uses: actions/checkout@v2 - - name: "Run SwiftLint" - run: swiftlint --reporter github-actions-logging - format-swift: runs-on: macos-latest steps: @@ -48,7 +40,6 @@ jobs: build-app: runs-on: macos-latest needs: - - lint-swift - format-swift - format-objc steps: diff --git a/.pre-commit b/.pre-commit new file mode 100755 index 0000000..606e5da --- /dev/null +++ b/.pre-commit @@ -0,0 +1 @@ +make app-autoformat diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..da16829 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +APPDIR := OpenHaystack + +default: + +install-hooks: .pre-commit + cp .pre-commit .git/hooks/pre-commit + +app-autoformat: + swift-format format -i -r $(APPDIR) + clang-format -i $(shell find $(APPDIR) -name '*.h' -o -name '*.m') diff --git a/OpenHaystack/.swiftlint.yml b/OpenHaystack/.swiftlint.yml deleted file mode 100644 index 0b66e5a..0000000 --- a/OpenHaystack/.swiftlint.yml +++ /dev/null @@ -1,59 +0,0 @@ - -# By default, SwiftLint uses a set of sensible default rules you can adjust: -disabled_rules: # rule identifiers turned on by default to exclude from running - - colon - - control_statement - - identifier_name - - force_try - -opt_in_rules: # some rules are turned off by default, so you need to opt-in - - empty_count # Find all the available rules by running: `swiftlint rules` - -# Alternatively, specify all rules explicitly by uncommenting this option: -# only_rules: # delete `disabled_rules` & `opt_in_rules` if using this -# - empty_parameters -# - vertical_whitespace - -analyzer_rules: # Rules run by `swiftlint analyze` (experimental) - - explicit_self - -# configurable rules can be customized from this configuration file -# binary rules can set their severity level -force_cast: warning # implicitly -# rules that have both warning and error levels, can set just the warning level -# implicitly -line_length: 180 -# they can set both implicitly with an array -type_body_length: - - 400 # warning - - 500 # error -# or they can set both explicitly -file_length: - warning: 600 - error: 1200 -# naming rules can set warnings/errors for min_length and max_length -# additionally they can set excluded names -type_name: - min_length: 1 # only warning - max_length: # warning and error - warning: 40 - error: 50 - excluded: - - iPhone - - BN - - ECC - - PSI - - Log - allowed_symbols: ["_"] # these are allowed in type names -identifier_name: - min_length: 1 # only min_length - excluded: # excluded via string array - - id - - URL - - GlobalAPIKey - - SHA256_SIZE - - SHA384_SIZE - - TWO - - EULER_THEOREM - - Log -reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging) diff --git a/OpenHaystack/OpenHaystack.xcodeproj/project.pbxproj b/OpenHaystack/OpenHaystack.xcodeproj/project.pbxproj index 8cb87af..ce0bb0b 100644 --- a/OpenHaystack/OpenHaystack.xcodeproj/project.pbxproj +++ b/OpenHaystack/OpenHaystack.xcodeproj/project.pbxproj @@ -50,7 +50,6 @@ 78EC226425DAE0BE0042B775 /* OpenHaystackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78EC226325DAE0BE0042B775 /* OpenHaystackTests.swift */; }; 78EC226C25DBC2E40042B775 /* OpenHaystackMainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78EC226B25DBC2E40042B775 /* OpenHaystackMainView.swift */; }; 78EC227225DBC8CE0042B775 /* Accessory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78EC227125DBC8CE0042B775 /* Accessory.swift */; }; - 78EC227525DBCCA00042B775 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 78EC227425DBCCA00042B775 /* .swiftlint.yml */; }; 78EC227725DBDB7E0042B775 /* KeychainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78EC227625DBDB7E0042B775 /* KeychainController.swift */; }; F16BA9E925E7DB2D00238183 /* NIOSSL in Frameworks */ = {isa = PBXBuildFile; productRef = F16BA9E825E7DB2D00238183 /* NIOSSL */; }; /* End PBXBuildFile section */ @@ -150,7 +149,6 @@ 78EC226525DAE0BE0042B775 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 78EC226B25DBC2E40042B775 /* OpenHaystackMainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenHaystackMainView.swift; sourceTree = ""; }; 78EC227125DBC8CE0042B775 /* Accessory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessory.swift; sourceTree = ""; }; - 78EC227425DBCCA00042B775 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; 78EC227625DBDB7E0042B775 /* KeychainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainController.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -211,7 +209,6 @@ isa = PBXGroup; children = ( 78286DDC25E56C9400F65511 /* README.md */, - 78EC227425DBCCA00042B775 /* .swiftlint.yml */, 78108B6E248E8FB50007E9C4 /* OpenHaystack */, 78EC226225DAE0BE0042B775 /* OpenHaystackTests */, 78286C8F25E3AC0400F65511 /* OpenHaystackMail */, @@ -370,9 +367,7 @@ isa = PBXNativeTarget; buildConfigurationList = 781EB40525DAD7EA00FEAA19 /* Build configuration list for PBXNativeTarget "OpenHaystack" */; buildPhases = ( - 78EC227325DBC9240042B775 /* Run SwiftLint */, F125DE4525F65E0700135D32 /* Run swift-format */, - F1D0A05C25F6BBC7004F9326 /* Run clang-format */, 781EB3E925DAD7EA00FEAA19 /* Sources */, 781EB3F625DAD7EA00FEAA19 /* Frameworks */, 781EB3FC25DAD7EA00FEAA19 /* Resources */, @@ -481,7 +476,6 @@ 78023CAF25F7797400B083EF /* ESP32 in Resources */, 7899D1D625DE74EE00115740 /* firmware.bin in Resources */, 781EB3FE25DAD7EA00FEAA19 /* MapViewController.xib in Resources */, - 78EC227525DBCCA00042B775 /* .swiftlint.yml in Resources */, 781EB40025DAD7EA00FEAA19 /* Preview Assets.xcassets in Resources */, 781EB40225DAD7EA00FEAA19 /* Assets.xcassets in Resources */, ); @@ -508,24 +502,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 78EC227325DBC9240042B775 /* Run SwiftLint */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Run SwiftLint"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if command -v swiftlint >/dev/null; then\n swiftlint autocorrect && swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; - }; F125DE4525F65E0700135D32 /* Run swift-format */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -542,7 +518,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if command -v swift-format >/dev/null; then\n swift-format format -r -i \"$SRCROOT\" && swift-format lint -r \"$SRCROOT\"\nelse\n echo \"warning: swift-format not installed, download from https://github.com/apple/swift-format\"\nfi\n"; + shellScript = "if command -v swift-format >/dev/null; then\n swift-format lint -r \"$SRCROOT\"\nelse\n echo \"warning: swift-format not installed, download from https://github.com/apple/swift-format\"\nfi\n"; }; F14B2C7E25EFBB11002DC056 /* Set Version Number from Git */ = { isa = PBXShellScriptBuildPhase; @@ -580,24 +556,6 @@ shellPath = /bin/sh; shellScript = "GIT_RELEASE_VERSION=$(git describe --tags --always --dirty)\nCOMMITS=$(git rev-list HEAD | wc -l)\nCOMMITS=$(($COMMITS))\ndefaults write \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\" \"CFBundleShortVersionString\" \"${GIT_RELEASE_VERSION#*v}\"\ndefaults write \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\" \"CFBundleVersion\" \"${COMMITS}\"\n"; }; - F1D0A05C25F6BBC7004F9326 /* Run clang-format */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Run clang-format"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if command -v clang-format >/dev/null; then\n clang-format -i \"$SRCROOT\"/**/*.{h,m}\nelse\n echo \"warning: clang-format not installed\"\nfi\n"; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */