Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Conversation

@afterxleep
Copy link
Contributor

@afterxleep afterxleep commented Jul 19, 2023

Task URL: https://app.asana.com/0/1200194497630846/1205110674679790/f

Descrption:

Adds a script that allows us to automatically install a pre-commit hook that runs swiftlint --fix

The original installation script lives in BSK for easier maintenance. App Scripts download it and install it locally. (Remote URL will be updated once we merge BSK. This script can be extended as necesary to install/manage additional pre-commit hooks

How to test:

  • Install the hook with ./scripts/pre-commit.sh --install

  • Add a few trail whitespaces to a file

  • Build the project

  • Commit the changes

  • Observe whitespace was magically cleaned up

  • Uninstall the hook with ./scripts/pre-commit.sh --install

  • Add a few trail whitespaces to a file

  • Build the project

  • Commit the changes

  • Observe whitespace warnings are still there

This hook also automatically correct the following rules:**

  • anyobject_protocol
  • closing_brace
  • closure_end_indentation
  • closure_spacing
  • colon
  • comma
  • comma_inheritance
  • comment_spacing
  • control_statement
  • direct_return
  • duplicate_imports
  • empty_enum_arguments
  • empty_parameters
  • empty_parentheses_with_trailing_closure
  • explicit_init
  • explicit_self
  • implicit_return
  • joined_default_parameter
  • leading_whitespace
  • legacy_cggeometry_functions
  • legacy_constant
  • legacy_constructor
  • legacy_nsgeometry_functions
  • literal_expression_end_indentation
  • lower_acl_than_parent
  • mark
  • modifier_order
  • nimble_operator
  • no_space_in_method_call
  • number_separator
  • opening_brace
  • operator_usage_whitespace
  • optional_enum_case_matching
  • period_spacing
  • prefer_self_in_static_references
  • prefer_self_type_over_type_of_self
  • prefer_zero_over_explicit_init
  • private_over_fileprivate
  • private_unit_test
  • protocol_property_accessors_order
  • redundant_discardable_let
  • redundant_nil_coalescing
  • redundant_objc_attribute
  • redundant_optional_initialization
  • redundant_self_in_closure
  • redundant_type_annotation
  • redundant_void_return
  • return_arrow_whitespace
  • self_binding
  • shorthand_optional_binding
  • sorted_imports
  • statement_position
  • strong_iboutlet
  • syntactic_sugar
  • test_case_accessibility
  • toggle_bool
  • trailing_comma
  • trailing_newline
  • trailing_semicolon
  • trailing_whitespace
  • unneeded_parentheses_in_closure_argument
  • unneeded_synthesized_initializer
  • untyped_error_in_catch
  • unused_closure_parameter
  • unused_control_flow_label
  • unused_import
  • vertical_whitespace
  • vertical_whitespace_between_cases
  • vertical_whitespace_closing_braces
  • vertical_whitespace_opening_braces
  • void_return

@afterxleep afterxleep changed the title Add —fix to the linter Add Commit hook install script Aug 4, 2023
@afterxleep afterxleep changed the title Add Commit hook install script Adds remote pre-commit installer, which includes automatic fix for linter Aug 4, 2023
Copy link
Collaborator

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

LGTM :) it works great after some updates I made to the BSK script, and you can also greatly simplify the pre-commit.sh script in this repo (see the comment below). Nice work!

afterxleep added a commit to duckduckgo/BrowserServicesKit that referenced this pull request Aug 23, 2023
Please review the release process for BrowserServicesKit here.

Required:
Task/Issue URL: https://app.asana.com/0/1200194497630846/1205110674679790/f
iOS PR: duckduckgo/iOS#1845
macOS PR: duckduckgo/macos-browser#1369
What kind of version bump will this require?: None, this is just a CI change

Descrption:

Adds a script that allows us to automatically install a pre-commit hook that runs swiftlint --fix

The original installation script lives in BSK for easier maintenance. App Scripts download it and install it locally. (Remote URL will be updated once we merge BSK. This script can be extended as necesary to install/manage additional pre-commit hooks
@afterxleep afterxleep merged commit 1e5954a into develop Aug 23, 2023
@afterxleep afterxleep deleted the daniel/lint-fix branch August 23, 2023 12:58
samsymons added a commit that referenced this pull request Aug 23, 2023
# By Diego Rey Mendez (7) and others
# Via Sam Symons (2) and others
* develop: (26 commits)
  Improve Sync-related database cleaning logic (#1529)
  Update onboarding-related error states (#1504)
  Prevents launching our menu agent without an auth code. (#1516)
  Autofill UI letter icons (#1535)
  Cleans up some code (#1517)
  Revert "Autofill Letter Icons" (#1534)
  Adds remote pre-commit installer, which includes automatic fix for linter (#1369)
  Autofill Letter Icons (#1475)
  change context menu for mailto links (#1513)
  Updates the version to 1.53.1
  Updated the embedded files for 1.53.1
  Update the phased rollout tester to avoid caching the config (#1520)
  Require Duck Player scheme URL to be passed from YouTube Overlay User Script (#1519)
  Add pixels related to Duck Player usage (#1515)
  only allow error reloads on http(s) urls (#1523)
  Standardize TDS Loading Error handling (#1524)
  Move pixel sender logic into the main view controller (#1528)
  Update the phased rollout tester to avoid caching the config (#1520)
  Set version to 1.52.3.
  Move pixel sender logic into the main view controller (#1528)
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	DuckDuckGo/AppDelegate/AppDelegate.swift
#	DuckDuckGo/Common/Localizables/UserText.swift
#	DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
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.

2 participants