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

Use yml arrays to list the ForbiddenImports #2463

Closed
BraisGabin opened this issue Mar 19, 2020 · 1 comment · Fixed by #2474
Closed

Use yml arrays to list the ForbiddenImports #2463

BraisGabin opened this issue Mar 19, 2020 · 1 comment · Fixed by #2474

Comments

@BraisGabin
Copy link
Member

BraisGabin commented Mar 19, 2020

This is right now my config for ForbiddenImports

  ForbiddenImport:
    active: true
    imports: 'kotlinx.android.synthetic.*,butterknife.*,org.mockito.*,java.util.List,java.util.Arrays,java.util.HashSet,java.util.Set,java.util.Map,java.util.HashMap,java.util.ArrayList,java.util.Collections.emptyList,java.util.Collections.singletonList,coches.net.core.extensions.bindView,coches.net.core.extensions.bindOptionalView,com.adevinta.android.extensions.view.bindView,com.adevinta.android.extensions.activity.bindView,com.adevinta.android.extensions.recycler.bindView,com.adevinta.android.extensions.fragment.bindView'

It's really difficult to manage and to review.

It would be great to allow this:

  ForbiddenImport:
    active: true
    imports:
    - 'kotlinx.android.synthetic.*'
    - 'butterknife.*'
    - 'org.mockito.*'
    - 'java.util.List'
    - 'java.util.Arrays'
    - 'java.util.HashSet'
    - 'java.util.Set'
    - 'java.util.Map'
    - 'java.util.HashMap'
    - 'java.util.ArrayList'
    - 'java.util.Collections.emptyList'
    - 'java.util.Collections.singletonList'
    - 'coches.net.core.extensions.bindView'
    - 'coches.net.core.extensions.bindOptionalView'
    - 'com.adevinta.android.extensions.view.bindView'
    - 'com.adevinta.android.extensions.activity.bindView'
    - 'com.adevinta.android.extensions.recycler.bindView'
    - 'com.adevinta.android.extensions.fragment.bindView'

What do you think? I'm sure that we can use this in other rules too.

Side Note: reformating the list of imports I just spoted a problem in it. It was impossible to spot it in the long list.

@arturbosch
Copy link
Member

arturbosch commented Mar 19, 2020

Yaml lists are more readable.
Back then we had a discussions to stay with comma separated strings for consistency.
However we could support both ways until a 2.0 and move to list syntax only.

e.g.

tryCatching { parseListSyntax() }
  .onError { parseStringSyntax().commaSeparatedList() }
  .getOrThrow { error -> <handle parent key sequence if using valueOrNull> }

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

Successfully merging a pull request may close this issue.

2 participants