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

0 kotlin files were analyzed while running on concourse #889

Closed
harry329 opened this issue May 2, 2018 · 7 comments
Closed

0 kotlin files were analyzed while running on concourse #889

harry329 opened this issue May 2, 2018 · 7 comments

Comments

@harry329
Copy link

harry329 commented May 2, 2018

build.gradle for module includes --
defaultProfile {
input = file("src/main/kotlin")

Current Behavior

while running locally ./gradlew detektCheck it works as expected but when I push my change to git and then on concourse it's not working as it's expected and output is -
0 kotlin files were analyzed

Steps to Reproduce (for bugs)

Run the task on Concourse.

Your Environment

  • Version used: 1.0.0.RC6-4
  • Operating System and version:
    • Local (working): Darwin xxx 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64
    • Concourse (not working): Linux 97707991-7ae1-4d7e-7c90-06fae3b2d57a 4.9.87-linuxkit-aufs Ideas for more code smell detectors? #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 Linux
  • Link to your project:
@arturbosch
Copy link
Member

Is concourse your project somewhere openly accessible?
Maybe your package naming has a word like build, resources or test in it and gets excluded by the default --filters property/configuration?

@harry329
Copy link
Author

harry329 commented May 7, 2018

Hi @arturbosch , thanks for your reply but our package name doesn't include any build, resources or test word.
The weird thing is the command ./gradlew detektCheck is working fine on our local machine but when we are trying to run it the same way on our build machine (we are using a Pivotal's Concourse to run a CI/CD pipeline) then it doesn't analyze any kotlin file.

Our configuration for the Detekt gradle tasks looks like below.
We are writing our own detekt.yml config file and pointing to it in the config.

detekt {
    version = detektVersion
    defaultProfile {
        input = file("src/main/kotlin")
        filters = ".*/resources/.*,.*/build/.*"
        config = file("src/main/resources/detekt.yml")
    }
}

@arturbosch
Copy link
Member

Are you sure that Concourse's user name is not build or resources xD ?
That's actually really strange. How does the console looks like?

@harry329
Copy link
Author

harry329 commented May 7, 2018

@arturbosch Thanks for the reply.
We took another look and saw that when the task was run on the Concourse container, the present working directory it runs under does include /tmp/build.
This is just how Concourse names the root of the Container under which the build runs.
Now the problem is that the value of filters option on the detekt task is relative to the root directory of the container and not to the module specific present working directory.
So of course it was skipping all files.
Now if we don't specify a value for filters, then the same happens because the default value gets added to the command line options.
So after putting a bogus filename as a value for filters, then we see detekt actually picking up the kotlin files.
Should we provide an empty string as the value for filters instead of a bogus file name, since we don't want it to skip anything and we need to prevent it from executing with the default command line options?
Thanks again.

@arturbosch
Copy link
Member

I think by just providing an empty string the default filters are not triggered. In your case it makes sense as your input parameter is pointing to src/main/kotlin.
Just make sure to add filters if input is projectDir etc (in our repo we have tons of test kotlin files in resources etc).
I'm closing as your issue is now resolved I guess. Feel free to open this or another if more questions occur!
PS: filters accept any regex you want

@harry329
Copy link
Author

harry329 commented May 8, 2018

@arturbosch Thanks for your help, empty string works fine for us.

@arturbosch arturbosch added this to the RC7-2 milestone Jun 1, 2018
@lock
Copy link

lock bot commented Jun 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants