不包装长参数列表的可能理由是什么? (StyleCop SA1115)
我陷入了 ReSharper 和 StyleCop 之间的战斗,我想让 ReSharper 获胜,但在这样做之前我想听听支持 StyleCop 的论点。
当我编写长参数列表时,ReSharper 会明智地截断参数列表并在下一行重新启动它。 我发现这更具可读性。
当我对代码运行 StyleCop 时,它希望我将这些行保留得很长。 我不喜欢这样,所以我想忽略 StyleCop 规则 (SA1115)。 我想不出 SC 一开始想要排这么长队的好理由——这只是“我们一直都是这样做的”吗?
I'm stuck in a battle between ReSharper and StyleCop, and I'd like to let ReSharper win, but I want to hear the arguments in favour of StyleCop before I do that.
When I'm writing long argument lists ReSharper sensibly chops the parameter list and restarts it on the next line. I find that much more readable.
When I run StyleCop over the code it wants me to leave those lines really long. I don't like that, so I want to ignore that StyleCop rule (SA1115). I can't think of a good reason why SC would want those long lines in the first place – is it just a case of "we've always done it this way"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
StyleCop 不希望您将所有参数放在很长的一行上。 但是,它也不希望您随意插入换行符以将参数列表的一部分向下移动到下一行。 StyleCop 希望您执行以下操作之一:
StyleCop doesn't want you to put all your parameters on one really long line. However, it also doesn't want you to just arbitrarily insert a newline to move part of the parameter list down to the next line. StyleCop would like you to do one of the following:
它可能是为了提醒您,您的论点列表太长,应该缩短。
It's probably there to remind you that your argument list is too long and should be shortened.
在使用此问题,我也通过从 VS IDE 运行 StyleCop 遇到了 SA1115 的问题。 经过一番思考后,StyleCop 觉得还不错的最终结果是:
只是想分享一下。
Whilst playing about with the code from this question, I also fell foul of SA1115 via running StyleCop from the VS IDE. After some mucking about, here is the end result which StyleCop felt was OK:
Just thought I'd share it.
似乎规则从技术上讲是“参数必须遵循逗号”。 如果你问我的话,我是相当挑剔的,但有些人相信用逗号开始续行才能真正显示嘿! 这句话是一个延续! 例如,
无论你的船是什么,就个人而言:)
It seems the rule technically says "parameter must follow comma." Pretty nit-picky if you ask me, but some people believe in starting continuation lines with the commas in order to really show hey! This line is a continuation! E.g.
Whatever floats your boat, personally :)