Yarn: Chore: add code duplication detection tool to lint step

Created on 11 Jul 2017  路  5Comments  路  Source: yarnpkg/yarn

Forking from https://github.com/yarnpkg/yarn/pull/3877#discussion_r126381876, I think it would be nice to add a code duplication detector to the lint stage (or as a separate stage) to avoid copy/pasting of commonly used functions.

A good project is https://yarnpkg.com/en/package/jsinspect but we may prefer https://yarnpkg.com/en/package/jscpd too.

Most helpful comment

I made a little research about those two tools, jsinspect seems more focused (supports flow syntax in AST comparison). It also has a gulp plugin. And I saw people claiming that jsinspect is faster and smarter than jscpd on javascript source. What do you think @BYK, @arcanis, @bestander, @voxsim, @kaylieEB?

All 5 comments

I made a little research about those two tools, jsinspect seems more focused (supports flow syntax in AST comparison). It also has a gulp plugin. And I saw people claiming that jsinspect is faster and smarter than jscpd on javascript source. What do you think @BYK, @arcanis, @bestander, @voxsim, @kaylieEB?

+1 for jsinspect then.

Let's try jsinspect :)

Any tool will be fine, however it would be best if they were only raising temporary warnings rather than preventing a merge altogether (or worse, breaking the lint on master). I'm all for factoring code, but in some situations similar-looking codes might have different semantics, and in this regard we should have the final word over the tool :)

Completely agree with @arcanis there. This should never fail the CI builds. It should only warn in linting.

Was this page helpful?
0 / 5 - 0 ratings