Skip to content

Commit

Permalink
Initial implementation (#1) (#2)
Browse files Browse the repository at this point in the history
* Adding project files

* Refactoring and revision of the entire API

Also adding example and updating tests

* Revised API and readme file

* Adding builders for state machine, state, and event
  • Loading branch information
insha authored May 3, 2023
1 parent 5adb329 commit a940f02
Show file tree
Hide file tree
Showing 30 changed files with 2,150 additions and 34 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/preflight-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Preflight Code Checks

on: pull_request

jobs:
Preflight-Code-Checks:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Check for Changes
id: repo-fetch-changes
run: |
echo "-> Source: ${{ github.head_ref }} (${{ github.event.pull_request.head.sha }})"
echo "-> Target: ${{ github.base_ref }} (${{ github.event.pull_request.base.sha }})"
# Fetching base ref
git fetch --prune --no-tags --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/heads/${{ github.base_ref }}
against=${{ github.event.pull_request.base.sha }}
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changed_files<<$EOF" >> $GITHUB_ENV
changed_files=$(git --no-pager diff-index --cached --diff-filter=ACMR --name-only --relative $against -- '*.swift')
echo "$changed_files" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Code Format Validation
if: env.changed_files != ''
run: |
modified_file_list="${{ github.workspace }}/modified_file_list"
echo "${{ env.changed_files }}" > $modified_file_list
swiftformat --filelist "$modified_file_list" --lint --config .swiftformat --swiftversion 5 --reporter github-actions-log
- name: Linting Code
if: env.changed_files != ''
run: |
modified_files=$(cat "${{ github.workspace }}/modified_file_list")
swiftlint lint --config .swiftlint --reporter "github-actions-logging" $modified_files
17 changes: 12 additions & 5 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
--exclude Tests, Scripts, Documentation
# format options

--exclude DerivedData, Documentation, Scripts, **/Package.swift

--disable redundantType

--indent 4
--allman true
--semicolons never
--wraparguments after-first
--elseposition next-line
--indentcase true
--patternlet inline
--semicolons never
--shortoptionals always
--stripunusedargs always
--trimwhitespace always
--wraparguments before-first
--wrapcollections before-first
--elseposition next-line
--patternlet inline
106 changes: 81 additions & 25 deletions .swiftlint
Original file line number Diff line number Diff line change
@@ -1,48 +1,104 @@
excluded:
- Tests
- DerivedData
- Documentation
- Scripts

disabled_rules:
- colon
- opening_brace
- trailing_comma
- closing_brace
- statement_position
- discarded_notification_center_observer
- switch_case_alignment
- identifier_name
- unused_setter_value
- multiple_closures_with_trailing_closure

opt_in_rules:
- private_outlet
- private_action
- anyobject_protocol
- collection_alignment
- convenience_type
- discouraged_object_literal
- discouraged_optional_collection
- force_unwrapping
- fatal_error_message
- fallthrough
- empty_string
- contains_over_first_not_nil
- empty_count
- empty_string
- fallthrough
- fatal_error_message
- first_where
- force_unwrapping
- private_action
- private_outlet
- sorted_imports

line_length: 150
analyzer_rules:
- unused_import

void_function_in_ternary:
severity: error
first_where:
severity: error
force_unwrapping:
severity: error
private_outlet:
severity: error
private_action:
severity: error
multiple_closures_with_trailing_closure:
severity: error
notification_center_detachment:
severity: error
empty_enum_arguments:
severity: error
empty_parentheses_with_trailing_closure:
severity: error
redundant_objc_attribute:
severity: error
fatal_error_message:
severity: error
fallthrough:
severity: error
empty_string:
severity: error
empty_count:
severity: error
return_arrow_whitespace:
severity: error
vertical_parameter_alignment:
severity: error
trailing_whitespace:
severity: error
vertical_whitespace:
severity: error

nesting:
type_level: 2

function_parameter_count:
warning: 4
error: 5
ignores_default_parameters: false

file_length:
warning: 450
error: 500
warning: 500
error: 600

line_length:
warning: 170
error: 180
ignores_comments: true

type_body_length:
warning: 300
warning: 250
error: 400

closure_body_length:
warning: 80
error: 100
type_name:
allowed_symbols: ["_"]
max_length:
warning: 50
error: 60

identifier_name:
allowed_symbols: ["_"]
excluded: ["id", "iv", "ok"]
severity: error

function_body_length:
warning: 100
error: 110

cyclomatic_complexity:
warning: 10
error: 20

reporter: "xcode"
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Helium is created, developed, and maintained by Farhan Ahmed.
Krypton is created, developed, and maintained by Farhan Ahmed.

A full list of contributors is available from git with:

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
How to contribute to Helium
===========================
How to contribute to Krypton
============================

Thank you for considering contributing to Helium!
Thank you for considering contributing to Krypton!

Reporting issues
----------------
Expand Down
Loading

0 comments on commit a940f02

Please sign in to comment.