Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Add Swiftformat to enforce consistent Swift style #73

Closed
wants to merge 1 commit into from

Conversation

michalsrutek
Copy link
Contributor

  • Added .swiftformat file with a set of rules to be enforced
  • Formatted code

The tool can be found here, list of all available rules here.

To format code, one simply calls swiftformat . from the project's directory.

This can be either set-up to be run on a CI server in the future, or as a build phase script.

Feedback appreciated.

Copy link
Member

@augard augard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not against. Just we will need to make little bit different rule list.

@michalsrutek
Copy link
Contributor Author

What are your suggestions / things you don't like?

@augard
Copy link
Member

augard commented Apr 14, 2020

whitelist_rules:
  - custom_rules
  - array_init
  - block_based_kvo
  - class_delegate_protocol
  - closing_brace
  - closure_end_indentation
  - closure_parameter_position
  - closure_spacing
  - collection_alignment
  - colon
  - comma
  - compiler_protocol_init
  - contains_over_first_not_nil
  - control_statement
  - deployment_target
  - discouraged_direct_init
  - discouraged_object_literal
  - duplicate_imports
  - dynamic_inline
  - empty_count
  - empty_enum_arguments
  - empty_parameters
  - empty_parentheses_with_trailing_closure
  - empty_string
  - explicit_init
  - fallthrough
  - fatal_error_message
  - first_where
  - for_where
  - force_cast
  - force_try
  - force_unwrapping
  - identical_operands
  - implicit_getter
  # - implicit_return
  - inert_defer
  - is_disjoint
  - joined_default_parameter
  - large_tuple
  - last_where
  - leading_whitespace
  - legacy_cggeometry_functions
  - legacy_constant
  - legacy_constructor
  - legacy_nsgeometry_functions
  - legacy_random
  - mark
  - modifier_order
  - multiple_closures_with_trailing_closure
  - number_separator
  - opening_brace
  - operator_usage_whitespace
  - overridden_super_call
  - private_over_fileprivate
  - protocol_property_accessors_order
  - reduce_boolean
  - reduce_into
  - redundant_discardable_let
  - redundant_nil_coalescing
  - redundant_objc_attribute
  - redundant_optional_initialization
  - redundant_set_access_control
  - redundant_type_annotation
  - redundant_void_return
  - return_arrow_whitespace
  - shorthand_operator
  - sorted_first_last
  - statement_position
  - superfluous_disable_command
  - switch_case_alignment
  - syntactic_sugar
  - todo
  - toggle_bool
  - trailing_newline
  - trailing_semicolon
  - trailing_whitespace
  - unneeded_break_in_switch
  - unneeded_parentheses_in_closure_argument
  - unowned_variable_capture
  - untyped_error_in_catch
  - unused_capture_list
  - unused_closure_parameter
  - unused_enumerated
  - unused_import
  - unused_optional_binding
  - valid_ibinspectable
  - vertical_parameter_alignment
  - vertical_parameter_alignment_on_call
  - vertical_whitespace
  - void_return
  - weak_delegate
  - yoda_condition
force_cast: error
force_unwrapping: error
empty_count: warning
function_body_length:
  - 100 # warning
  - 300 # error
type_body_length:
  - 300 # warning
  - 500 # error
file_length:
  warning: 500
  error: 1200

@augard
Copy link
Member

augard commented Apr 14, 2020

Now I realized you are using swiftformat

@augard
Copy link
Member

augard commented Apr 14, 2020

I wanted to add swiftlint and swiftgen (to generate storyboard strings to enums)

@ddmus
Copy link
Collaborator

ddmus commented Apr 14, 2020

SwiftLint is imho more popular and used. Anyway, our problem is not format of code, but BT advertising and scanning. And updating to latest figma changes.

@michalsrutek
Copy link
Contributor Author

Closing for now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants