1 /* 2 * Copyright (c) 2011-2024 Qulice.com 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.maven; 32 33 import com.qulice.checkstyle.CheckstyleValidator; 34 import com.qulice.pmd.PmdValidator; 35 import com.qulice.spi.Environment; 36 import com.qulice.spi.ResourceValidator; 37 import com.qulice.spi.Validator; 38 import java.util.Arrays; 39 import java.util.Collection; 40 import java.util.LinkedHashSet; 41 import java.util.Set; 42 43 /** 44 * Provider of validators. 45 * 46 * @since 0.3 47 * @checkstyle ClassDataAbstractionCoupling (500 lines) 48 */ 49 final class DefaultValidatorsProvider implements ValidatorsProvider { 50 /** 51 * Environment to use for validation. 52 */ 53 private final Environment env; 54 55 /** 56 * Constructor. 57 * @param env Environment to use for validation. 58 */ 59 DefaultValidatorsProvider(final Environment env) { 60 this.env = env; 61 } 62 63 @Override 64 public Set<MavenValidator> internal() { 65 final Set<MavenValidator> validators = new LinkedHashSet<>(); 66 validators.add(new PomXpathValidator()); 67 validators.add(new EnforcerValidator()); 68 validators.add(new DuplicateFinderValidator()); 69 validators.add(new SvnPropertiesValidator()); 70 validators.add(new DependenciesValidator()); 71 validators.add(new SnapshotsValidator()); 72 return validators; 73 } 74 75 @Override 76 public Set<Validator> external() { 77 return new LinkedHashSet<>(); 78 } 79 80 @Override 81 public Collection<ResourceValidator> externalResource() { 82 return Arrays.asList( 83 new CheckstyleValidator(this.env), 84 new PmdValidator(this.env) 85 ); 86 } 87 }