Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftLint #45

Merged
merged 4 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: SwiftLint

on:
push:
branches:
- master
paths:
- '.github/workflows/swiftlint.yml'
- '**/.swiftlint.yml'
- '**.swift'
pull_request:
branches:
- master
paths:
- '.github/workflows/swiftlint.yml'
- '**/.swiftlint.yml'
- '**.swift'
workflow_dispatch:

jobs:
swiftlint:
name: SwiftLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: norio-nomura/action-swiftlint@3.2.1
with:
args: --strict
104 changes: 104 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
disabled_rules:
- nesting
- trailing_comma
opt_in_rules:
- anonymous_argument_in_multiline_closure
- array_init
- attributes
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- comma_inheritance
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- convenience_type
- discouraged_assert
- discouraged_none_name
- discouraged_object_literal
- discouraged_optional_boolean
- discouraged_optional_collection
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- expiring_todo
- explicit_init
- file_header
- file_name
- file_name_no_space
- first_where
- flatmap_over_map_reduce
- force_unwrapping
- function_default_parameter_at_end
- identical_operands
- implicitly_unwrapped_optional
- indentation_width
- joined_default_parameter
- last_where
- legacy_multiple
- legacy_objc_type
- let_var_whitespace
- literal_expression_end_indentation
- local_doc_comment
- lower_acl_than_parent
- modifier_order
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- no_extension_access_modifier
- nslocalizedstring_key
- number_separator
- operator_usage_whitespace
- optional_enum_case_matching
- overridden_super_call
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- prefer_zero_over_explicit_init
- prohibited_super_call
- raw_value_for_camel_cased_codable_enum
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- return_value_from_void_function
- self_binding
- shorthand_optional_binding
- sorted_first_last
- static_operator
- toggle_bool
- trailing_closure
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- weak_delegate
- yoda_condition

analyzer_rules:
- unused_declaration
- unused_import

identifier_name:
allowed_symbols:
- '_'
excluded:
- x
- y

line_length:
- 130
- 200

trailing_whitespace:
ignores_empty_lines: true

type_name:
allowed_symbols:
- '_'
18 changes: 12 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,34 @@ let package = Package(
dependencies: [
.target(name: "SwiftPackageListCore"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]),
]
),
.target(
name: "SwiftPackageListCore",
dependencies: ["SwiftPackageList"]),
dependencies: ["SwiftPackageList"]
),
.target(name: "SwiftPackageList"),
.target(name: "SwiftPackageListObjc"),
.target(
name: "SwiftPackageListUI",
dependencies: ["SwiftPackageList"],
resources: [.process("Resources")]),
resources: [.process("Resources")]
),
.testTarget(name: "SwiftPackageListCommandTests"),
.testTarget(
name: "SwiftPackageListCoreTests",
dependencies: ["SwiftPackageListCore"],
resources: [.copy("Resources")]),
resources: [.copy("Resources")]
),
.testTarget(
name: "SwiftPackageListTests",
dependencies: ["SwiftPackageList"],
resources: [.process("Resources")]),
resources: [.process("Resources")]
),
.testTarget(
name: "SwiftPackageListObjcTests",
dependencies: ["SwiftPackageListObjc"],
resources: [.process("Resources")]),
resources: [.process("Resources")]
),
]
)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Tweet](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2FFelixHerrmann%2Fswift-package-list)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2FFelixHerrmann%2Fswift-package-list)

[![Xcode Build](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/xcodebuild.yml/badge.svg)](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/xcodebuild.yml)
[![SwiftLint](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/FelixHerrmann/swift-package-list/actions/workflows/swiftlint.yml)

A command-line tool to generate a JSON, PLIST, Settings.bundle or PDF file with all used SPM-dependencies of an Xcode project or workspace.

Expand Down
4 changes: 4 additions & 0 deletions Sources/SwiftPackageList/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
opt_in_rules:
- explicit_acl
- fatal_error_message
- missing_docs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//
// Models.swift
// Package.swift
// SwiftPackageList
//
// Created by Felix Herrmann on 02.11.21.
// Created by Felix Herrmann on 11.03.23.
//

import Foundation

// MARK: - Package

/// A package object in the package-list file.
public struct Package: Hashable, Codable {

Expand Down Expand Up @@ -47,12 +45,3 @@ public struct Package: Hashable, Codable {
self.license = license
}
}

// MARK: - PackageList

/// The possible thrown errors of the `packageList(bundle:fileName:)` function.
public enum PackageListError: Error {

/// Couldn't find a package-list file in the specified bundle for the specified file name.
case noPackageList
}
13 changes: 13 additions & 0 deletions Sources/SwiftPackageList/PackageListError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// PackageListError.swift
// SwiftPackageList
//
// Created by Felix Herrmann on 11.03.23.
//

/// The possible thrown errors of the `packageList(bundle:fileName:)` function.
public enum PackageListError: Error {

/// Couldn't find a package-list file in the specified bundle for the specified file name.
case noPackageList
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// SwiftPackageListCore+ArgumentParser.swift
// FileType+ExpressibleByArgument.swift
// SwiftPackageListCommand
//
// Created by Felix Herrmann on 19.05.22.
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftPackageListCommand/SwiftPackageListCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ struct SwiftPackageListCommand: ParsableCommand {
@Option(name: .shortAndLong, help: "The path where the package-list file will be stored.")
var outputPath: String = "\(NSHomeDirectory())/Desktop"

// swiftlint:disable:next line_length
@Option(name: .shortAndLong, help: "The file type of the generated package-list file. Available options are json, plist, settings-bundle and pdf.")
var fileType: FileType = .json

@Option(name: .shortAndLong, help: "A custom filename to be used instead of the default ones.")
var customFileName: String?

@Flag(help: "Will skip the packages without a license-file.")
var requiresLicense: Bool = false
var requiresLicense = false

mutating func run() throws {
guard let project = Project(path: projectPath) else {
Expand All @@ -47,7 +48,7 @@ struct SwiftPackageListCommand: ParsableCommand {
}

let checkoutsDirectory: URL
if let sourcePackagesPath = sourcePackagesPath {
if let sourcePackagesPath {
checkoutsDirectory = URL(fileURLWithPath: sourcePackagesPath).appendingPathComponent("checkouts")
} else {
guard let buildDirectory = try project.buildDirectory(in: derivedDataPath) else {
Expand Down
Loading