Package com.puppycrawl.tools.checkstyle.api

Examples of com.puppycrawl.tools.checkstyle.api.Configuration


     * @param results The results to summarize
     * @param previousCategory The previous row's category
     */
    private void doRuleRow( ConfReference ref, CheckstyleResults results, String previousCategory )
    {
        Configuration checkerConfig = ref.configuration;
        ChainedItem<Configuration> parentConfiguration = ref.parentConfiguration;
        String ruleName = checkerConfig.getName();

        sink.tableRow();

        // column 1: rule category
        sink.tableCell();
        String category = ref.category;
        if ( !category.equals( previousCategory ) )
        {
            sink.text( category );
        }
        sink.tableCell_();

        // column 2: Rule name + configured attributes
        sink.tableCell();
        if ( !"extension".equals( category ) )
        {
            sink.link( "http://checkstyle.sourceforge.net/config_" + category + ".html#" + ruleName );
            sink.text( ruleName );
            sink.link_();
        }
        else
        {
            sink.text( ruleName );
        }

        List<String> attribnames = new ArrayList<String>( Arrays.asList( checkerConfig.getAttributeNames() ) );
        attribnames.remove( "severity" ); // special value (deserves unique column)
        if ( !attribnames.isEmpty() )
        {
            sink.list();
            for ( String name : attribnames )
View Full Code Here


        if ( filterSet != null )
        {
            checker.addFilter( filterSet );
        }
        Configuration configuration = getConfiguration( request );
        checker.configure( configuration );

        AuditListener listener = request.getListener();

        if ( listener != null )
View Full Code Here

            // so we have to fix it
            ClassLoader checkstyleClassLoader = PackageNamesLoader.class.getClassLoader();
            Thread.currentThread().setContextClassLoader( checkstyleClassLoader );
            String configFile = getConfigFile( request );
            Properties overridingProperties = getOverridingProperties( request );
            Configuration config = ConfigurationLoader
                .loadConfiguration( configFile, new PropertiesExpander( overridingProperties ) );
            String effectiveEncoding = StringUtils.isNotEmpty( request.getEncoding() ) ? request.getEncoding() : System
                .getProperty( "file.encoding", "UTF-8" );
           
            if ( StringUtils.isEmpty( request.getEncoding() ) )
            {
                request.getLog().warn(
                                       "File encoding has not been set, using platform encoding " + effectiveEncoding
                                           + ", i.e. build is platform dependent!" );
            }

            if ( "Checker".equals( config.getName() )
                    || "com.puppycrawl.tools.checkstyle.Checker".equals( config.getName() ) )
            {
                if ( config instanceof DefaultConfiguration )
                {
                    // MCHECKSTYLE-173 Only add the "charset" attribute if it has not been set
                    try
                    {
                        if ( config.getAttribute( "charset" ) == null )
                        {
                            ( (DefaultConfiguration) config ).addAttribute( "charset", effectiveEncoding );
                        }
                    }
                    catch ( CheckstyleException ex )
                    {
                        // Checkstyle 5.4+ throws an exception when trying to access an attribute that doesn't exist
                        ( (DefaultConfiguration) config ).addAttribute( "charset", effectiveEncoding );
                    }
                }
                else
                {
                    request.getLog().warn( "Failed to configure file encoding on module " + config );
                }
            }
            Configuration[] modules = config.getChildren();
            for ( Configuration module : modules )
            {
                if ( "TreeWalker".equals( module.getName() )
                    || "com.puppycrawl.tools.checkstyle.TreeWalker".equals( module.getName() ) )
                {
View Full Code Here

    }

    /** @param aFileName the cache file */
    public void setCacheFile(String aFileName)
    {
        final Configuration configuration = getConfiguration();
        mCache = new PropertyCacheFile(configuration, aFileName);
    }
View Full Code Here

                               String aQName)
            throws SAXException
        {
            if (aQName.equals(MODULE)) {

                Configuration recentModule = (Configuration) mConfigStack.pop();

                // remove modules with severity ignore if these modules should
                // be omitted
                SeverityLevel level = null;
                try {
                    final String severity = recentModule.getAttribute(SEVERITY);
                    level = SeverityLevel.getInstance(severity);
                }
                catch (CheckstyleException e) {
                    //severity not set -> ignore
                    ;
View Full Code Here

        if (!line.hasOption("c")) {
            System.out.println("Must specify a config XML file.");
            usage();
        }

        final Configuration config = loadConfig(line, props);

        //Load the set of package names
        ModuleFactory moduleFactory = null;
        if (line.hasOption("n")) {
            moduleFactory = loadPackages(line);
View Full Code Here

    private Checker createChecker()
    {
        Checker c = null;
        try {
            final Properties props = createOverridingProperties();
            final Configuration config = ConfigurationLoader.loadConfiguration(
                    mConfigLocation, new PropertiesExpander(props), true);

            final DefaultContext context = new DefaultContext();
            final ClassLoader loader = new AntClassLoader(getProject(),
                    mClasspath);
View Full Code Here

        public void run() {
            try {
                int tabWidth = DEFAULT_TAB_WIDTH;
                final Checker checker = new Checker();
                Configuration config = null;

                if (location != null) {
                    InputStream configurationInputStream = null;

                    try {
View Full Code Here

            configurationLocationStatus = ConfigurationLocationStatus.BLACKLISTED;
            return null;
        }

        final CheckerContainer checkerContainer = getChecker(module, moduleClassLoader, location);
        final Configuration config = getConfig(module, location);
        if (checkerContainer == null || config == null) {
            return Collections.emptyMap();
        }

        final List<Check> checks = CheckFactory.getChecks(config);
View Full Code Here

                                         final Module module)
            throws IOException {
        ScannableFile scannableFile = null;
        try {
            final CheckerContainer checkerContainer = getChecker(checkStylePlugin, module);
            final Configuration config = getConfig(checkStylePlugin, module);
            if (checkerContainer == null || config == null) {
                return new ProblemDescriptor[0];
            }

            final List<Check> checks = CheckFactory.getChecks(config);
View Full Code Here

TOP

Related Classes of com.puppycrawl.tools.checkstyle.api.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.