2

Having trouble where to find a specific solution to disable Missing newline after ":" and Missing newline after "," of ktlint rules, when running ktlintCheck in my kotlin codes in Android

This is my code that encounters error:

class MainActivity : BaseActivity(),
   DateSelectionListener, AttachmentsSelectionListener,
   LocationStateListener
{

}

This is what the ktlint requires me to format my code:

class MainActivity : BaseActivity(), DateSelectionListener, AttachmentsSelectionListener, LocationStateListener
{

}

I just wanted to bring the interfaces below one another since bunch of interfaces consumes too much of code line.

I Am Arien
  • 79
  • 2
  • 7
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Mar 04 '22 at 00:45

1 Answers1

3

You should be able to use ktlint-disable comments, like:

// you can use a block comment
/* ktlint-disable parameter-list-wrapping */
class MainActivity : BaseActivity(),
   DateSelectionListener, AttachmentsSelectionListener,
   LocationStateListener
{

}
/* ktlint-enable parameter-list-wrapping */

// or eol comment
class MainActivity : BaseActivity(),
   DateSelectionListener, AttachmentsSelectionListener, // ktlint-disable parameter-list-wrapping
   LocationStateListener
{

}

Looks like v0.46.x of ktlint also supports suppressing checks via @Suppress, but the gradle plugin hasn't caught up yet, though it looks like a pr is in draft.

boggebe
  • 31
  • 3