Code Monkey home page Code Monkey logo

Comments (5)

xuantan avatar xuantan commented on June 25, 2024

@smiler158 看看可以统一提供一个集成的样例

from p3c.

smiler158 avatar smiler158 commented on June 25, 2024

p3c规则是基于pmd规则上修改而来,可以直接参数pmd与jekins集成文档,将规则包换成p3c的包就可以,可参考 http://blog.csdn.net/hwhua1986/article/details/48342745 。 另插件已在云效公有云产品中集成,立即体验!https://rdc-test.aliyun.com/

from p3c.

smiler158 avatar smiler158 commented on June 25, 2024

另附,直接使用p3c-pmd包扫描示例。
java -cp p3c-pmd.jar net.sourceforge.pmd.PMD -d /usr/src -R rule/ali-comment.xml -f text
参数解释:
-d 源码目录
-R 指定规则,多个规则以,号分开
-f 报告格式,text html等。

from p3c.

ouyangpeng avatar ouyangpeng commented on June 25, 2024

@zmywly8866 尴尬,我提了个Issue,然后看到了你提的Issue。#182

@smiler158 回复说是基于pmd规则做的,那么应该是可以配置检测到Issue规则的话就停止编译。

task pmd(type: Pmd) {
    description 'Run PMD'
    group 'verification'

    ignoreFailures = false
    ruleSetFiles = files("$configDir/pmd/pmd-ruleset.xml")
    ruleSets = []

    source 'src'
    include '**/*.java'
    exclude '**/gen/**'

    reports {
        xml.enabled = false
        html.enabled = true
        xml {
            destination "$reportsDir/pmd/pmd.xml"
        }
        html {
            destination "$reportsDir/pmd/pmd.html"
        }
    }
}

pmd的规则类似

<?xml version="1.0"?>
<!--
  ~ Copyright 2015 Vincent Brison.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Android Application Rules"
    xmlns="http://pmd.sf.net/ruleset/1.0.0"
    xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
    xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">

    <description>Custom ruleset for Android application</description>

    <exclude-pattern>.*/R.java</exclude-pattern>
    <exclude-pattern>.*/gen/.*</exclude-pattern>

    <!-- Android -->
    <!-- http://pmd.sourceforge.net/pmd-4.3.0/rules/android.html -->
    <rule ref="rulesets/java/android.xml"/>

    <!-- Design -->
    <!-- http://pmd.sourceforge.net/pmd-4.3.0/rules/design.html -->
    <rule ref="rulesets/java/design.xml">
        <exclude name="UncommentedEmptyMethod"/>
    </rule>

    <!-- Naming -->
    <!-- http://pmd.sourceforge.net/pmd-4.3.0/rules/naming.html -->
    <rule ref="rulesets/java/naming.xml/ShortClassName">
        <properties>
            <property name="minimum" value="3"/>
        </properties>
    </rule>
    <!-- other rules ignored for brevity -->

    <rule ref="rulesets/java/clone.xml" />
    <rule ref="rulesets/java/finalizers.xml" />
    <rule ref="rulesets/java/imports.xml">
        <!-- Espresso is designed this way !-->
        <exclude name="TooManyStaticImports" />
    </rule>
    <rule ref="rulesets/java/logging-java.xml" />
    <rule ref="rulesets/java/braces.xml" />
    <rule ref="rulesets/java/strings.xml" />
    <rule ref="rulesets/java/basic.xml" />
    <rule ref="rulesets/java/naming.xml">
        <exclude name="AbstractNaming" />
        <exclude name="LongVariable" />
        <exclude name="ShortMethodName" />
        <exclude name="ShortVariable" />
        <exclude name="VariableNamingConventions" />
    </rule>
</ruleset>

@smiler158 只是阿里这个插件的rules是否可以列出来呢??

from p3c.

michael-ancestor avatar michael-ancestor commented on June 25, 2024

maven下使用p3c-pmd检测不出来任何问题,使用插件是可以检测出来的

from p3c.

Related Issues (20)

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.