CheckStyle模块可防止“太多”回车?

问题描述

是否有一个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>

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...