Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 182ecf2

Browse files
committed
Merge pull request #60 from codeclimate/will/command-line-running
Use .capture3 not .popen3 for external parsers
2 parents f528659 + 0982eeb commit 182ecf2

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

‎lib/cc/engine/analyzers/command_line_runner.rb‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,11 @@ def initialize(command, timeout = DEFAULT_TIMEOUT)
1414

1515
def run(input)
1616
Timeout.timeout(timeout) do
17-
Open3.popen3 command, "r+" do |stdin, stdout, stderr, wait_thr|
18-
stdin.puts input
19-
stdin.close
20-
21-
exit_code = wait_thr.value
22-
23-
output = stdout.gets
24-
stdout.close
25-
26-
err_output = stderr.gets
27-
stderr.close
28-
29-
if 0 == exit_code
30-
yield output
31-
else
32-
raise ::CC::Engine::Analyzers::ParserError, "Python parser exited with code #{exit_code}:\n#{err_output}"
33-
end
17+
out, err, status = Open3.capture3(command, stdin_data: input)
18+
if status.success?
19+
yield out
20+
else
21+
raise ::CC::Engine::Analyzers::ParserError, "`#{command}` exited with code #{status.exitstatus}:\n#{err}"
3422
end
3523
end
3624
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /