Skip to content

Commit

Permalink
[MCHECKSTYLE-374] - replace deprecated method calls with newer
Browse files Browse the repository at this point in the history
checkstyle version
  • Loading branch information
rnveach committed Apr 23, 2019
1 parent 6704658 commit ba2aea8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.puppycrawl.tools.checkstyle.DefaultLogger;
import com.puppycrawl.tools.checkstyle.XMLLogger;
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;

/**
Expand Down Expand Up @@ -628,11 +629,11 @@ protected AuditListener getListener()

if ( "xml".equals( outputFileFormat ) )
{
listener = new XMLLogger( out, true );
listener = new XMLLogger( out, OutputStreamOptions.CLOSE );
}
else if ( "plain".equals( outputFileFormat ) )
{
listener = new DefaultLogger( out, true );
listener = new DefaultLogger( out, OutputStreamOptions.CLOSE );
}
else
{
Expand Down Expand Up @@ -681,13 +682,13 @@ protected DefaultLogger getConsoleListener()
if ( useFile == null )
{
stringOutputStream = new ByteArrayOutputStream();
consoleListener = new DefaultLogger( stringOutputStream, false );
consoleListener = new DefaultLogger( stringOutputStream, OutputStreamOptions.NONE );
}
else
{
OutputStream out = getOutputStream( useFile );

consoleListener = new DefaultLogger( out, true );
consoleListener = new DefaultLogger( out, OutputStreamOptions.CLOSE );
}

return consoleListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.puppycrawl.tools.checkstyle.DefaultLogger;
import com.puppycrawl.tools.checkstyle.XMLLogger;
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;

/**
Expand Down Expand Up @@ -731,13 +732,13 @@ private DefaultLogger getConsoleListener()
if ( useFile == null )
{
stringOutputStream = new ByteArrayOutputStream();
consoleListener = new DefaultLogger( stringOutputStream, false );
consoleListener = new DefaultLogger( stringOutputStream, OutputStreamOptions.NONE );
}
else
{
OutputStream out = getOutputStream( useFile );

consoleListener = new DefaultLogger( out, true );
consoleListener = new DefaultLogger( out, OutputStreamOptions.CLOSE );
}

return consoleListener;
Expand Down Expand Up @@ -778,7 +779,7 @@ private AuditListener getListener()

if ( "xml".equals( outputFileFormat ) )
{
listener = new XMLLogger( out, true );
listener = new XMLLogger( out, OutputStreamOptions.CLOSE );
}
else if ( "plain".equals( outputFileFormat ) )
{
Expand All @@ -790,8 +791,8 @@ else if ( "plain".equals( outputFileFormat ) )
outputXmlFile.deleteOnExit();
OutputStream xmlOut = getOutputStream( outputXmlFile );
CompositeAuditListener compoundListener = new CompositeAuditListener();
compoundListener.addListener( new XMLLogger( xmlOut, true ) );
compoundListener.addListener( new DefaultLogger( out, true ) );
compoundListener.addListener( new XMLLogger( xmlOut, OutputStreamOptions.CLOSE ) );
compoundListener.addListener( new DefaultLogger( out, OutputStreamOptions.CLOSE ) );
listener = compoundListener;
}
catch ( IOException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.PackageNamesLoader;
import com.puppycrawl.tools.checkstyle.PropertiesExpander;
import com.puppycrawl.tools.checkstyle.ConfigurationLoader.IgnoredModulesOptions;
import com.puppycrawl.tools.checkstyle.api.AuditListener;
import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.Configuration;
Expand Down Expand Up @@ -373,9 +374,18 @@ public Configuration getConfiguration( CheckstyleExecutorRequest request )
Thread.currentThread().setContextClassLoader( checkstyleClassLoader );
String configFile = getConfigFile( request );
Properties overridingProperties = getOverridingProperties( request );
IgnoredModulesOptions omitIgnoredModules;
if ( request.isOmitIgnoredModules() )
{
omitIgnoredModules = IgnoredModulesOptions.OMIT;
}
else
{
omitIgnoredModules = IgnoredModulesOptions.EXECUTE;
}
Configuration config =
ConfigurationLoader.loadConfiguration( configFile, new PropertiesExpander( overridingProperties ),
request.isOmitIgnoredModules() );
omitIgnoredModules );
String effectiveEncoding = StringUtils.isNotEmpty( request.getEncoding() ) ? request.getEncoding() : System
.getProperty( "file.encoding", "UTF-8" );

Expand Down

0 comments on commit ba2aea8

Please sign in to comment.