GitHub user VampireAchao edited a comment on the discussion: StreamPark 
code-style-and-quality Improve

Unreasonable branch order results in multiple lines of code depth+1.
Generally speaking, if a method has a code line depth exceeding 2+ tabs (In 
Streampark, one TAB is equivalent to two spaces) due to nested if...else.., 
consider trying to merge branches, invert branch conditions, or extract private 
methods to reduce code line depth and enhance readability.

```java
    if (request instanceof MultipartHttpServletRequest) {
      MultipartHttpServletRequest multipartRequest = 
(MultipartHttpServletRequest) request;
      Map<String, MultipartFile> files = multipartRequest.getFileMap();
      for (String file : files.keySet()) {
        MultipartFile multipartFile = multipartRequest.getFile(file);
        ApiAlertException.throwIfNull(
            multipartFile, "File to upload can't be null. Upload file failed.");
        boolean fileType = 
FileUtils.isJarFileType(multipartFile.getInputStream());
        ApiAlertException.throwIfFalse(
            fileType, "Illegal file type, Only support standard jar files. 
Upload file failed.");
      }
    }
    return true;


----->>


    if (!(request instanceof MultipartHttpServletRequest)) {
        return true;
    } 
    MultipartHttpServletRequest multipartRequest = 
(MultipartHttpServletRequest) request;
    Map<String, MultipartFile> files = multipartRequest.getFileMap();
    for (String file : files.keySet()) {
      MultipartFile multipartFile = multipartRequest.getFile(file);
      ApiAlertException.throwIfNull(
          multipartFile, "File to upload can't be null. Upload file failed.");
      boolean fileType = 
FileUtils.isJarFileType(multipartFile.getInputStream());
      ApiAlertException.throwIfFalse(
          fileType, "Illegal file type, Only support standard jar files. Upload 
file failed.");
    }
    return true;



--------------------
```

GitHub link: 
https://github.com/apache/incubator-streampark/discussions/2915#discussioncomment-6623985

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to