GithubHelp home page GithubHelp logo

sbt / sbt-cpd Goto Github PK

View Code? Open in Web Editor NEW
48.0 12.0 10.0 129 KB

Copy & Paste Detector plugin using PMD for sbt.

License: Eclipse Public License 1.0

Scala 100.00%
sbt sbt-plugin cpd scala pmd static-analysis

sbt-cpd's Introduction

CI Latest version Discord

sbt

sbt is a build tool for Scala, Java, and more.

For general documentation, see https://www.scala-sbt.org/.

sbt 1.x

This is the 1.x series of sbt. The source code of sbt is split across several GitHub repositories, including this one.

  • sbt/io hosts sbt.io module.
  • sbt/librarymanagement hosts sbt.librarymanagement module that wraps Ivy.
  • sbt/zinc hosts Zinc, an incremental compiler for Scala.
  • sbt/sbt, this repository hosts modules that implements the build tool.

Other links

  • Setup: Describes getting started with the latest binary release.
  • FAQ: Explains how to get help and more.
  • sbt/sbt-zero-seven: hosts sbt 0.7.7 and earlier versions

Issues and Pull Requests

Please read CONTRIBUTING carefully before opening a GitHub Issue.

The short version: try searching or asking on StackOverflow.

license

See LICENSE.

sbt-cpd's People

Contributors

corux avatar hairyfotr avatar jentsch avatar nightscape avatar stringbean avatar sumito3478 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-cpd's Issues

How does it work

Hi, I just added the CPD plugin into one of my projects. Now, I am just wondering How does it work, I already have some duplicate code in my project but It never mentioned it in the CPD.xml. It was working fine with projects I was doing earlier.

Misleading readme.md

Hi,
I tried this plug-in and I like it.

But in order to modify the default settings for ReportTypeor OutputType I had to insert import de.johoop.cpd4sbt._ and to use e.g. ReportType.Simple / OutputType.Console instant of CPDReportType / CPDOutputType.

Is this intended or little error in the documentation? If this is an error, I would be glade to provide an fix.

Kind regards
Jentsch

Does cpd4sbt support multiple languages on the same project?

In version 1.1.5 it was possible to add multi-language support by:

val cpdJava = TaskKey[Unit]("cpdJava", "CPD for java")

lazy val prj = (project in file("."))
  .settings(
     // ....
    // CPD for Scala sources
    CopyPasteDetector.cpdSettings,    
    cpdMinimumTokens := 75,
    cpdTargetPath := target.value,
    cpdReportName := "cpd-scala-report.xml",
    cpdLanguage := Language.Scala,

    // CPD for Java sources
    cpdJava <<= (cpdReportSettings, cpdSourceSettings, cpdMaxMemoryInMB, cpdClasspath, streams) map {
      (report, settings, mem, path, streams) => cpdAction(
        report.copy(name = "cpd-java-report.xml"),
        // TODO: remove or adjust minTokens.
        settings.copy(language = Language.Java, minTokens = 45),
        mem,
        path,
        streams
      )
    },

    // Run CPD for Java before CPD for Scala
    cpd <<= cpd dependsOn cpdJava,
   // ....
}

How it can be done in 1.2.0 ?

sbt-cpd pulls SNAPSHOT dependency for pmd-apex

Expected vs Actual Behaviour

It should...
not cause using projects to pull SNAPSHOT dependencies

Instead it...
it causes using projects to pull apex-jorje-ide-1.0-sfdc-187-SNAPSHOT-55042bfc2e

Steps to Reproduce

setup an sbt project and add

addSbtPlugin("com.github.sbt" %% "sbt-cpd" % "2.0.0")

try to start an sbt session

[info] Resolved  dependencies
[warn] 
[warn]  Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading apex:apex-jorje-semantic:1.0-sfdc-187-SNAPSHOT-55042bfc2e
...

Environment

  • sbt version: 1.5.4
  • Plugin version: 2.0.0
  • Scala version(s): 2.11.11 and 2.12.12 (include all versions if cross-building)_
  • Java version: 1.8
  • Link to project source: n.a.

Error log when skipping duplicate files

Because of Issue #13, I have to specify the option to skip duplicate files:
cpdSkipDuplicateFiles := true

It seems to work, but my SBT console displays each time errors:
[error] Skipping /home/file.scala since it appears to be a duplicate file and --skip-duplicate-files is set.

This should not be an error: that's the expected behaviour, and not having a spam of red log messages.

It thinks whole file is duplicated

When I integrate the cpd4sbt 1.2.0, I got the result like

<?xml version="1.0" encoding="utf-8"?>
<pmd-cpd>
   <duplication lines="408" tokens="2626">
      <file line="1" path="D:\program\rrx\app\services\WechatService.scala"/>
      <file line="1" path="D:\program\rrx\app\services\WechatService.scala"/>
      <codefragment><![CDATA[package services
import java.security.MessageDigest
...

It seems whole file is duplicated, and there are all my scala files in the xml file.
build.sbt:

lazy val root = (project in file(".")).enablePlugins(PlayScala, CopyPasteDetector, BuildInfoPlugin).
  settings(
    buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
    buildInfoPackage := "tool"
  )

plugins.sbt

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

addSbtPlugin("de.johoop" % "cpd4sbt" % "1.2.0")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.