问题描述
是否有一个CheckStyle模块可以模仿以下行为?
对于Java + IntelliJ。
使用StyleCop,它将在本地检查“太多”回车符。
示例C#代码:
请注意“使用System.Collections.Generic”下面的行和方法“ GetSingle”上方的行..它们有多于一个的空行。
StyleCop会抱怨,您可以在该空间中保留1或0个空行来解决此问题。
我在https://checkstyle.sourceforge.io/config_whitespace.html找不到任何东西
或者我不知道我要找的是什么神奇的词。
namespace Examples.UnitTestingWithInMemoryLoggingExample.SimulatedProject.Bal.Managers
{
using System;
using System.Collections.Generic;
using Examples.UnitTestingWithInMemoryLoggingExample.SimulatedProject.Bal.Managers.Interfaces;
using Examples.UnitTestingWithInMemoryLoggingExample.SimulatedProject.Dal.Interfaces;
using Examples.UnitTestingWithInMemoryLoggingExample.SimulatedProject.Domain;
using Surescripts.Components.Logging.LoggingAbstractBase;
public class EmployeeManager : IEmployeeManager
{
public const string ErrorMessageILoggerFactoryWrapperIsNull = "ILoggerFactoryWrapper is null";
public const string ErrorMessageIEmployeeDataIsNull = "IEmployeeData is null";
public const string LogMsgEmployeeManagerGetAll = "EmployeeManager.GetAll started";
public const string LogMsgEmployeeManagerGetSingle = "EmployeeManager.GetSingle started (key='{0}')";
public const string LogMsgKeyLessThanZero = "Warning Warning Warning. Key less than zero. (key='{0}')";
private readonly ILoggerWrapper<EmployeeManager> logger;
private readonly IEmployeeData empData;
public EmployeeManager(ILoggerFactoryWrapper loggerFactory,IEmployeeData empData)
{
if (null == loggerFactory)
{
throw new ArgumentNullException(ErrorMessageILoggerFactoryWrapperIsNull,(Exception)null);
}
this.logger = loggerFactory.CreateLoggerWrapper<EmployeeManager>();
this.empData = empData ?? throw new ArgumentNullException(ErrorMessageIEmployeeDataIsNull,(Exception)null);
}
public ICollection<Employee> GetAll()
{
this.logger.LogInformation(LogMsgEmployeeManagerGetAll);
ICollection<Employee> returnItems = this.empData.GetAll();
return returnItems;
}
public Employee GetSingle(long key)
{
this.logger.LogInformation(string.Format(LogMsgEmployeeManagerGetSingle,key));
if (key < 0)
{
/* simple example to show IsEnabled */
if (this.logger.IsEnabled(LoggingEventTypeEnum.Warning))
{
this.logger.Log(new LogEntry(LoggingEventTypeEnum.Warning,string.Format(LogMsgKeyLessThanZero,key)));
}
}
Employee returnItem = this.empData.GetSingle(key);
return returnItem;
}
}
}
解决方法
找到了
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
</module>