Package com.puppycrawl.tools.checkstyle.api

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


        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

        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())) {
                    if (module instanceof DefaultConfiguration) {
                        //MCHECKSTYLE-132 DefaultConfiguration addAttribute has changed in checkstyle 5.3
View Full Code Here

        catch ( CheckstyleException e )
        {
            // Try to find the attribute in a parent, if there are any
            if ( parentConfigurations != null && !parentConfigurations.isEmpty() )
            {
                Configuration parentConfiguration = parentConfigurations.get( parentConfigurations.size() - 1 );
                List<Configuration> newParentConfigurations = new ArrayList<Configuration>( parentConfigurations );
                // Remove the last parent
                newParentConfigurations.remove( parentConfiguration );
                ret = getConfigAttribute( parentConfiguration, newParentConfigurations, attributeName, defaultValue );
            }
View Full Code Here

        {
            // Log the parent configuration path
            StringBuilder parentPath = new StringBuilder();
            for ( Iterator<Configuration> iterator = parentConfigurations.iterator(); iterator.hasNext(); )
            {
                Configuration parentConfiguration = iterator.next();
                parentPath.append( parentConfiguration.getName() );
                if ( iterator.hasNext() )
                {
                    parentPath.append( " --> " );
                }
            }
            if ( parentPath.length() > 0 )
            {
                getLog().debug( "Parent Configuration Path: " + parentPath.toString() );
            }
        }

        Configuration configChildren[] = configuration.getChildren();
        for (Configuration aConfigChildren : configChildren) {
            String ruleName = aConfigChildren.getName();

            if (treeWalkerNames.contains(ruleName)) {
                // special sub-case
View Full Code Here

        catch ( CheckstyleException e )
        {
            // Try to find the attribute in a parent, if there are any
            if ( parentConfigurations != null && !parentConfigurations.isEmpty() )
            {
                Configuration parentConfiguration = parentConfigurations.get( parentConfigurations.size() - 1 );
                List<Configuration> newParentConfigurations = new ArrayList<Configuration>( parentConfigurations );
                // Remove the last parent
                newParentConfigurations.remove( parentConfiguration );
                ret = getConfigAttribute( parentConfiguration, newParentConfigurations, attributeName, defaultValue );
            }
View Full Code Here

        {
            // Log the parent configuration path
            StringBuilder parentPath = new StringBuilder();
            for ( Iterator<Configuration> iterator = parentConfigurations.iterator(); iterator.hasNext(); )
            {
                Configuration parentConfiguration = iterator.next();
                parentPath.append( parentConfiguration.getName() );
                if ( iterator.hasNext() )
                {
                    parentPath.append( " --> " );
                }
            }
            if ( parentPath.length() > 0 )
            {
                getLog().debug( "Parent Configuration Path: " + parentPath.toString() );
            }
        }

        Configuration configChildren[] = configuration.getChildren();
        for ( int cci = 0; cci < configChildren.length; cci++ )
        {
            String ruleName = configChildren[cci].getName();

            if ( "TreeWalker".equals( ruleName ) )
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 ( ( (DefaultConfiguration) 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 ( int i = 0; i < modules.length; i++ )
            {
                Configuration module = modules[i];
                if ( "TreeWalker".equals( module.getName() )
                    || "com.puppycrawl.tools.checkstyle.TreeWalker".equals( module.getName() ) )
                {
                    if ( module instanceof DefaultConfiguration )
                    {
                        //MCHECKSTYLE-132 DefaultConfiguration addAttribute has changed in checkstyle 5.3
                        try
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.