Crash if there is no newline at the end of the file on Linux
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 2.4k
- Forks
- 237
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
We use sourceKitten in the following way: sourcekitten doc --spm-module <ourModule>" and everything is fine.
But if there is a *.swift file without a newline at the end of the file we get the following error:
/usr/lib/ruby/2.3.0/json/common.rb:156:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
from /usr/lib/ruby/2.3.0/json/common.rb:156:in `new'
from /usr/lib/ruby/2.3.0/json/common.rb:156:in `parse'
from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:794:in `parse'
from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:145:in `build_docs_for_sourcekitten_output'
from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:77:in `build'
from /var/lib/gems/2.3.0/gems/jazzy-0.9.3/bin/jazzy:15:in `<top (required)>'
from /usr/local/bin/jazzy:23:in `load'
from /usr/local/bin/jazzy:23:in `<main>'
But only on linux (we use the container norionomura/jazzy:0.9.3_swift-4.1.2 to build it on linux)
(This happens to us, because some developers in our team don't use Xcode, which adds always a newline at the end of the file)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce sourcekitten doc --spm-module <yourModule> on Linux with a Swift file that lacks a final newline, then inspect the generated output alongside the JSON parsing failure shown in the stack trace. Done means the command completes without the JSON parser crash and produces documentation for the affected module.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby, swift
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100