umamaheswararao edited a comment on pull request #2185:
URL: https://github.com/apache/hadoop/pull/2185#issuecomment-689992391


   I think the following new lines added into this method. Thats the reason it 
is reporting longer method warning..
   
   ```
   } else if (src.startsWith(Constants.CONFIG_VIEWFS_LINK_REGEX)) {
           final String target = si.getValue();
           String linkKeyPath = null;
           final String linkRegexPrefix = Constants.CONFIG_VIEWFS_LINK_REGEX + 
".";
           // settings#.linkKey
           String settingsAndLinkKeyPath = 
src.substring(linkRegexPrefix.length());
           int settingLinkKeySepIndex = settingsAndLinkKeyPath
               .indexOf(RegexMountPoint.SETTING_SRCREGEX_SEP);
           if (settingLinkKeySepIndex == -1) {
             // There's no settings
             linkKeyPath = settingsAndLinkKeyPath;
             settings = null;
           } else {
             // settings#.linkKey style configuration
             // settings from settings#.linkKey
             settings =
                 settingsAndLinkKeyPath.substring(0, settingLinkKeySepIndex);
             // linkKeyPath
             linkKeyPath = settingsAndLinkKeyPath.substring(
                 settings.length() + RegexMountPoint.SETTING_SRCREGEX_SEP
                     .length());
           }
           linkType = LinkType.REGEX;
           linkEntries.add(
               new LinkEntry(linkKeyPath, target, linkType, settings, ugi,
                   config));
           continue;
         }
   
   .......
   .......
   
    case REGEX:
             LOGGER.info("Add regex mount point:" + le.getSrc()
                 + ", target:" + le.getTarget()
                 + ", interceptor settings:" + le.getSettings());
             RegexMountPoint regexMountPoint =
                 new RegexMountPoint<T>(
                     this, le.getSrc(), le.getTarget(), le.getSettings());
             regexMountPoint.initialize();
             regexMountPointList.add(regexMountPoint);
             continue;
   
   ```
   
   Probably we can extract this logics to separate methods.
   I understand it needs multiple values needs to get from extarcted method, 
they are settings, linkType etc. Probably you can create LinkEntry in method 
and return LinkEntry. From there you can set linkType, settings etc.
   Check if they are possible to reduce lines in that method.
   
   move the following code to a small check method. There are two places we are 
doing same checks.
   ```
   if (src.length() != linkMergeSlashPrefix.length()) {
             throw new IOException("ViewFs: Mount points initialization error." 
+
                 " Invalid " + Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH +
                 " entry in config: " + src);
           }
   ```
   At end of the method we have some logics for handle no mount points code. IF 
we need we could extract that to handleNoMountPoints method or so.
   
   Check if this refactoring can make checkstyle happy and code can look 
cleaner.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to