1 /* 2 * Copyright (c) 2011-2025 Yegor Bugayenko 3 * 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 1) Redistributions of source code must retain the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer. 2) Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following 12 * disclaimer in the documentation and/or other materials provided 13 * with the distribution. 3) Neither the name of the Qulice.com nor 14 * the names of its contributors may be used to endorse or promote 15 * products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 20 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 package com.qulice.pmd; 32 33 import java.util.Arrays; 34 import java.util.Collection; 35 import org.hamcrest.Matchers; 36 import org.junit.jupiter.params.ParameterizedTest; 37 import org.junit.jupiter.params.provider.MethodSource; 38 39 /** 40 * Tests for disabled rules. 41 * @since 0.16 42 * @checkstyle MethodsOrderCheck (77 lines) 43 */ 44 final class PmdDisabledRulesTest { 45 46 @ParameterizedTest 47 @MethodSource("parameters") 48 void disablesRules(final String rule) throws Exception { 49 new PmdAssert( 50 String.format("%s.java", rule), 51 Matchers.any(Boolean.class), 52 Matchers.not( 53 Matchers.containsString( 54 String.format("(%s)", rule) 55 ) 56 ) 57 ).validate(); 58 } 59 60 @SuppressWarnings("PMD.ProhibitPublicStaticMethods") 61 public static Collection<String[]> parameters() { 62 return Arrays.asList( 63 new String[][] { 64 {"UseConcurrentHashMap"}, 65 {"DoNotUseThreads"}, 66 {"AvoidUsingVolatile"}, 67 {"DefaultPackage"}, 68 {"ExcessiveImports"}, 69 {"PositionLiteralsFirstInComparisons"}, 70 {"MissingSerialVersionUID"}, 71 {"CallSuperInConstructor"}, 72 } 73 ); 74 } 75 76 }