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

Feature/check code duplication #19

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

eiditakahashi
Copy link
Contributor

@eiditakahashi eiditakahashi commented Feb 24, 2017

For now we have this setup:

  • To use CPD, projects will need to set some variables on their Dangerfile:
    • @minimum_tokens, @language, @directory, @ssh, @target_branch
    • if any of these variables is not set CDP will not run showing a warning
  • To run on CI we need to install pmd:
    • for projects using travis, we add - brew install pmd in .travis.yml
    • for projects using Jenkins, we add - brew install pmd in Jenkins script configuration

I am testing danger features here, the last warning is from CPD.

Depending on project CPD can turn in a bottleneck because it clones the repo to do comparison between feature branch and target branch. Here we can see that danger was executed in 41 seconds with CPD on this repo but I know that there are some huge repos (1GB+) 😕

So what you guys think about this approach @felipesabino @melloflavio

Pending:

  • Install pmd on docker image
  • Remove temporary directory (target-branch) to avoid garbage on local runs
  • Check if pmd is not present on current build
  • Update README list with this check

@felipesabino
Copy link
Contributor

To use CPD, projects will need to set some variables on their Dangerfile:

My only fear is that we will start to have several loose variables on Dangerfile. Don't know the best apporach, may be using a Hash only for pmd values to be more explicit?

for projects using Jenkins, we add - brew install pmd in Jenkins script configuration

We can also install it on the docker image we use, then we don't have to wait for the installation on every build


Also:

  • Can we warn if PMD is not present on current build? (travis.yml might be misconfigured for example and we should not crash if that's the case)
  • Do you think we should experiment on copying and pasting current folder to another location and reseting it to @target_branch instead of cloning? No idea if it will be faster for big repos (specially as the CI also perform shallow clone)

@felipesabino
Copy link
Contributor

Oh, forgot about remembering you to add a TODO/Pending here update README before finishing this PR

Dangerfile Outdated

def run_cpd_on_target_branch
`git clone --depth 1 #{@ssh} --branch #{@target_branch} target-branch`
`pmd cpd --language #{@language} --minimum-tokens #{@minimum_tokens} --files target-branch/#{@directory} --ignore-identifiers | grep tokens | wc -l`.to_i
Copy link
Contributor

Choose a reason for hiding this comment

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

may be remove target-branch afterwards to avoid garbage on local runs

@eiditakahashi eiditakahashi force-pushed the feature/check-code-duplication branch 4 times, most recently from 43c96f7 to 49373df Compare March 15, 2017 15:39
@eiditakahashi eiditakahashi force-pushed the feature/check-code-duplication branch 2 times, most recently from b17a27c to f443aff Compare May 10, 2017 22:10
@eiditakahashi eiditakahashi force-pushed the feature/check-code-duplication branch from f443aff to 234c98d Compare June 13, 2017 16:58
@eiditakahashi eiditakahashi force-pushed the feature/check-code-duplication branch from 234c98d to 3c2bc0f Compare June 21, 2017 18:47
@eiditakahashi eiditakahashi force-pushed the feature/check-code-duplication branch from 3c2bc0f to 9f0f671 Compare July 25, 2017 16:11
@eiditakahashi eiditakahashi force-pushed the feature/check-code-duplication branch from 9f0f671 to f2fb7cc Compare July 25, 2017 19:02
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

Successfully merging this pull request may close these issues.

2 participants