这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@rubinstory
Copy link

Changed: RunCommandService Refactored

eyi-jin added 2 commits May 29, 2022 23:55
In function `onStartCommand()`, It's too long(about 200 lines).
So extract the methods and reduce it to 58 lines.
Extract theses -> `getCanonicalPath()`,`checkSymlink()`,`checkInvalidWorkingDirectory()`,`startTermuxService()`,
`checkInvalidFile()`,`checkExecutable()`,`checkInvalidAppPolicy()`,`createExecutionIntent()`,
`getSomeExecutionCommand()`,`checkInvalidAction()`,`replaceComma2Char()`,`checkRunner()`.
TermuxPluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false);
return stopService();
}
Integer invalidRunner = checkRunner(intent, executionCommand);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just return false from function and do

if(!checkRunner()) return stopService()

@agnostic-apollo
Copy link
Member

Also the RunCommandService is gonna be refactored and split soon for new API design, so above changes will be lost.

@rubinstory
Copy link
Author

@agnostic-apollo
We didn't know that this file will be refactored and splitted, so we'll just close this PR.

@rubinstory rubinstory closed this May 30, 2022
@agnostic-apollo
Copy link
Member

Apart from checkInvalidAction() extraction, these were reasonable changes, although sequence of function definitions should have been the same as they were called. Split will indeed remove some stuff, specially intent extraction and creation, I currently haven't decided on final design, but already have a local implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants