<tfoot id='9SLHX'></tfoot>
      <i id='9SLHX'><tr id='9SLHX'><dt id='9SLHX'><q id='9SLHX'><span id='9SLHX'><b id='9SLHX'><form id='9SLHX'><ins id='9SLHX'></ins><ul id='9SLHX'></ul><sub id='9SLHX'></sub></form><legend id='9SLHX'></legend><bdo id='9SLHX'><pre id='9SLHX'><center id='9SLHX'></center></pre></bdo></b><th id='9SLHX'></th></span></q></dt></tr></i><div id='9SLHX'><tfoot id='9SLHX'></tfoot><dl id='9SLHX'><fieldset id='9SLHX'></fieldset></dl></div>

    1. <legend id='9SLHX'><style id='9SLHX'><dir id='9SLHX'><q id='9SLHX'></q></dir></style></legend>
        <bdo id='9SLHX'></bdo><ul id='9SLHX'></ul>
    2. <small id='9SLHX'></small><noframes id='9SLHX'>

      1. 方法有8个参数,大于7个授权

        Method has 8 parameters, which is greater than 7 authorized(方法有8个参数,大于7个授权)

            • <legend id='CCxFy'><style id='CCxFy'><dir id='CCxFy'><q id='CCxFy'></q></dir></style></legend>
                <i id='CCxFy'><tr id='CCxFy'><dt id='CCxFy'><q id='CCxFy'><span id='CCxFy'><b id='CCxFy'><form id='CCxFy'><ins id='CCxFy'></ins><ul id='CCxFy'></ul><sub id='CCxFy'></sub></form><legend id='CCxFy'></legend><bdo id='CCxFy'><pre id='CCxFy'><center id='CCxFy'></center></pre></bdo></b><th id='CCxFy'></th></span></q></dt></tr></i><div id='CCxFy'><tfoot id='CCxFy'></tfoot><dl id='CCxFy'><fieldset id='CCxFy'></fieldset></dl></div>
                • <bdo id='CCxFy'></bdo><ul id='CCxFy'></ul>
                    <tbody id='CCxFy'></tbody>

                  <small id='CCxFy'></small><noframes id='CCxFy'>

                  <tfoot id='CCxFy'></tfoot>
                • 本文介绍了方法有8个参数,大于7个授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我使用 sonar lint 扫描代码时,以下代码显示错误为方法有 8 个参数,大于 7 个授权"

                  When I am scanning code with sonar lint the following code shows the bug as "Method has 8 parameters, which is greater than 7 authorized"

                  @PutMapping("/something")
                  public List<SomeList> updateSomeThing(@PathVariable final SomeCode code,
                                                              @PathVariable final SomeId id, 
                                                              @PathVariable final String testId,
                                                              @PathVariable final String itemId,
                                                              @RequestBody final List<Test> someList,
                                                              @RequestHeader("test") final String testHeader,
                                                              final HttpServletRequest request,
                                                              final SomeHeaders someHeaders)
                  

                  注意:这是一个控制器方法,我们不能跳过任何参数

                  Note: This is a controller method we can not skip any parameters

                  仅供参考:Eclipse 将快速修复显示为 squid:S00107

                  FYI: Eclipse showing a quick fix as squid:S00107

                  有人知道如何解决这个错误吗?

                  Anybody have any idea how to resolve this bug?

                  推荐答案

                  这里有两件事要考虑.

                  1. 您可以在 Sonar 中调整此规则并增加授权参数的数量.说它是 10 而不是默认值 (?) 7.

                  UPD:以下建议基于旧问题版本.它可能不再适用于新的问题上下文.

                  UPD: the advice below is based on the old question version. It might be not applicable to the new question context any more.

                  1. 但通常你应该重新考虑你的方法接口.有很多参数意味着您的架构中可能有问题,并且单一责任原则可能会被打破.
                  1. But generally you should reconsider your method interface. Having many arguments means that something can be wrong in your architecture and the Single responsibility principle might be broken.

                  在您的特定示例中,我希望您可以拥有一个聚合类 Order:

                  Say in your particular example, I would expect, that you can have an aggregate class Order:

                  public class Order {
                     private CountryCode countryCode;
                     private String orderId;
                     private User user;
                     private String orderId;
                     private String item;
                     private List<Person> persons;
                     private ShippingAddress address;
                     private PaymentMethod payment;
                     private Product product;
                     // ...
                  }
                  

                  管理起来更合乎逻辑,而不是处理许多参数.然后您的问题将自动解决:

                  Which is much logical to manage instead of dealing with many parameters. Then your issues will be solved automatically:

                  @GetMapping
                  public void updateSomething(Order order) { ... }
                  

                  这篇关于方法有8个参数,大于7个授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  1. <legend id='5A9NL'><style id='5A9NL'><dir id='5A9NL'><q id='5A9NL'></q></dir></style></legend>

                    <small id='5A9NL'></small><noframes id='5A9NL'>

                    <i id='5A9NL'><tr id='5A9NL'><dt id='5A9NL'><q id='5A9NL'><span id='5A9NL'><b id='5A9NL'><form id='5A9NL'><ins id='5A9NL'></ins><ul id='5A9NL'></ul><sub id='5A9NL'></sub></form><legend id='5A9NL'></legend><bdo id='5A9NL'><pre id='5A9NL'><center id='5A9NL'></center></pre></bdo></b><th id='5A9NL'></th></span></q></dt></tr></i><div id='5A9NL'><tfoot id='5A9NL'></tfoot><dl id='5A9NL'><fieldset id='5A9NL'></fieldset></dl></div>
                      <tbody id='5A9NL'></tbody>

                      • <tfoot id='5A9NL'></tfoot>

                            <bdo id='5A9NL'></bdo><ul id='5A9NL'></ul>