<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个授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Slf4j LoggerFactory.getLogger and sonarqube(Slf4j LoggerFactory.getLogger 和 sonarqube)
                  Security - Array is stored directly(安全性 - 数组直接存储)
                  SonarQube quot;Class Not Foundquot; during Main AST Scan(SonarQube“找不到类在主 AST 扫描期间)
                  Integrate Spock#39;s test with Sonar(将 Spock 的测试与声纳集成)
                  How do I make Hudson/Jenkins fail if Sonar thresholds are breached?(如果违反声纳阈值,我如何让 Hudson/Jenkins 失败?)
                  automatically add curly brackets to all if/else/for/while etc. in a java code-base(自动将大括号添加到 java 代码库中的所有 if/else/for/while 等)
                  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>