JuliaDiff / JuliaDiff/BlueStyle
Soften guidelines for `return`
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 519
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
When using long-form functions always use the
returnkeyword
We may want adjust the the hard stance on using return with long-form functions. Some examples that adding in the return makes things worse:
function load!(tz_source::TZSource, file::AbstractString)
open(file, "r") do io
load!(tz_source, file, io)
end
end
# VS
function load!(tz_source::TZSource, file::AbstractString)
return open(file, "r") do io
load!(tz_source, file, io)
end
end
function isarchive(path)
@static if Sys.iswindows()
success(`$exe7z t $path -y`)
else
success(`tar tf $path`)
end
end
# VS
function isarchive(path)
return @static if Sys.iswindows()
success(`$exe7z t $path -y`)
else
success(`tar tf $path`)
end
end
function VariableTimeZone(name::AbstractString, args...)
new(name, args...)
end
# VS
function VariableTimeZone(name::AbstractString, args...)
return new(name, args...)
end
function extract(archive, directory, files=AbstractString[]; verbose::Bool=false)
...
run(cmd)
end
# VS
function extract(archive, directory, files=AbstractString[]; verbose::Bool=false)
...
return run(cmd) # Note: We don't actually want to return anything from this function
end
I would suggest we re-word to something like:
When using long-form functions prefer the use the
returnkeyword especially when control flow constructs are used. Avoid the use ofreturnwhen your function should not return anything.
Contributor guide
No contributing guide indexed for this repository
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
No file or test is named in the issue. Start by locating the guideline containing “When using long-form functions always use the return keyword,” then compare its wording with the supplied examples and proposed revision. Done means the guideline is softened to distinguish control-flow returns from functions that should not return a value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100