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

Ktlint failes to pass check in actions with ktlint formatted code #58

Open
Taewan-P opened this issue Feb 27, 2025 · 0 comments
Open

Ktlint failes to pass check in actions with ktlint formatted code #58

Taewan-P opened this issue Feb 27, 2025 · 0 comments

Comments

@Taewan-P
Copy link

Taewan-P commented Feb 27, 2025

Hello! I am having a trouble with the GitHub Actions ktlint and the local ktlint in my environment.

In my local environment, I use ktlint --format to format my code. However, this formatted code fails to pass the check using action-ktlint.

First, here is my .editorconfig.

[*.{kt,kts}]
ktlint_code_style = android_studio
end_of_line = lf
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_imports_layout = *
ij_kotlin_packages_to_use_import_on_demand = java.util.*,kotlinx.android.synthetic.**
indent_size = 4
indent_style = space
insert_final_newline = true
ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = unset
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
ktlint_code_style = android_studio
ktlint_function_naming_ignore_when_annotated_with = [unset]
ktlint_function_signature_body_expression_wrapping = default
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
ktlint_ignore_back_ticked_identifier = false
max_line_length = off
ktlint_function_naming_ignore_when_annotated_with=Composable
compose_allowed_state_holder_names = .*ViewModel,.*Presenter,.*Component

Next, here is the GitHub Actions yml file

name: Kotlin Lint Check

on:
  pull_request_target:
    branches:
      - "main"
    paths-ignore:
      - ".gitignore"
      - "**.md"
      - "LICENSE"
      - ".idea/**"
      - ".github/**"
      - ".editorconfig"
      - "images/**"
      - "metadata/**"

jobs:
  ktlint:
    name: Check Kotlin Code Format
    runs-on: ubuntu-latest

    steps:
      - name: Clone repo
        uses: actions/checkout@v4

      - name: Run ktlint
        uses: ScaCap/action-ktlint@master
        with:
          filter_mode: nofilter
          github_token: ${{ secrets.github_token }}
          reporter: github-check

Here is the code that makes the problem and the lint error.

@ExperimentalMaterial3Api
@Composable
fun pinnedExitUntilCollapsedScrollBehavior(
    state: TopAppBarState = rememberTopAppBarState(),
    canScroll: () -> Boolean = { true },
    snapAnimationSpec: AnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow),
    flingAnimationSpec: DecayAnimationSpec<Float>? = rememberSplineBasedDecay()
): TopAppBarScrollBehavior = PinnedExitUntilCollapsedScrollBehavior(
    state = state,
    snapAnimationSpec = snapAnimationSpec,
    flingAnimationSpec = flingAnimationSpec,
    canScroll = canScroll
)

Now the code above is formatted in my device using ktlint --format

Image

Local environment ktlint version: 1.5.0

What seems to be the problem? I first assumed that the action is not using .editorconfig file, but after reading #22 that was not the case.

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

No branches or pull requests

1 participant