Skip to content

Commit e91c0ff

Browse files
authored
Deprecate no space between expression and ? in ternaries (#22523)
* Deprecate no space between expression and ? in ternary * Replace uses of expr? in Base
1 parent 2c85595 commit e91c0ff

File tree

16 files changed

+40
-38
lines changed

16 files changed

+40
-38
lines changed

base/cartesian.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function exprresolve(ex::Expr)
417417
if ex.head == :if
418418
can_eval, tf = exprresolve_conditional(ex.args[1])
419419
if can_eval
420-
ex = tf?ex.args[2]:ex.args[3]
420+
ex = tf ? ex.args[2] : ex.args[3]
421421
end
422422
end
423423
ex

base/docs/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ avgdistance(xs) =
253253
function fuzzyscore(needle, haystack)
254254
score = 0.
255255
is, acro = bestmatch(needle, haystack)
256-
score += (acro?2:1)*length(is) # Matched characters
256+
score += (acro ? 2 : 1)*length(is) # Matched characters
257257
score -= 2(length(needle)-length(is)) # Missing characters
258258
!acro && (score -= avgdistance(is)/10) # Contiguous
259259
!isempty(is) && (score -= mean(is)/100) # Closer to beginning
@@ -330,7 +330,7 @@ function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = displays
330330
total = 0
331331
for i = 1:length(ss)
332332
total += length(ss[i])
333-
total + max(i-2,0)*length(delim) + (i>1?1:0)*length(last) > cols && (i-=1; break)
333+
total + max(i-2,0)*length(delim) + (i>1 ? 1 : 0)*length(last) > cols && (i-=1; break)
334334
end
335335
join(io, ss[1:i], delim, last)
336336
end

base/filesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ include("path.jl")
5252
include("stat.jl")
5353
include("file.jl")
5454
include("poll.jl")
55-
include(string(length(Core.ARGS)>=2?Core.ARGS[2]:"","file_constants.jl")) # include($BUILDROOT/base/file_constants.jl)
55+
include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "file_constants.jl")) # include($BUILDROOT/base/file_constants.jl)
5656

5757
## Operations with File (fd) objects ##
5858

base/libc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if is_windows()
1010
export GetLastError, FormatMessage
1111
end
1212

13-
include(string(length(Core.ARGS)>=2?Core.ARGS[2]:"","errno_h.jl")) # include($BUILDROOT/base/errno_h.jl)
13+
include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "errno_h.jl")) # include($BUILDROOT/base/errno_h.jl)
1414

1515
## RawFD ##
1616

base/libgit2/commit.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
function message(c::GitCommit, raw::Bool=false)
44
local msg_ptr::Cstring
5-
msg_ptr = raw? ccall((:git_commit_message_raw, :libgit2), Cstring, (Ptr{Void},), c.ptr) :
6-
ccall((:git_commit_message, :libgit2), Cstring, (Ptr{Void},), c.ptr)
5+
msg_ptr = raw ? ccall((:git_commit_message_raw, :libgit2), Cstring, (Ptr{Void},), c.ptr) :
6+
ccall((:git_commit_message, :libgit2), Cstring, (Ptr{Void},), c.ptr)
77
if msg_ptr == C_NULL
88
return nothing
99
end

base/libuv.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Core definitions for interacting with the libuv library from Julia
44

5-
include(string(length(Core.ARGS)>=2?Core.ARGS[2]:"","uv_constants.jl")) # include($BUILDROOT/base/uv_constants.jl)
5+
include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "uv_constants.jl")) # include($BUILDROOT/base/uv_constants.jl)
66

77
# convert UV handle data to julia object, checking for null
88
function uv_sizeof_handle(handle)

base/linalg/bidiag.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ julia> Bidiagonal(A, false) #contains the main diagonal and first subdiagonal of
142142
⋅ ⋅ 4 4
143143
```
144144
"""
145-
Bidiagonal(A::AbstractMatrix, isupper::Bool)=Bidiagonal(diag(A), diag(A, isupper?1:-1), isupper)
145+
Bidiagonal(A::AbstractMatrix, isupper::Bool)=Bidiagonal(diag(A), diag(A, isupper ? 1 : -1), isupper)
146146

147147
function getindex(A::Bidiagonal{T}, i::Integer, j::Integer) where T
148148
if !((1 <= i <= size(A,2)) && (1 <= j <= size(A,2)))
@@ -241,7 +241,7 @@ function show(io::IO, M::Bidiagonal)
241241
println(io, summary(M), ":")
242242
print(io, " diag:")
243243
print_matrix(io, (M.dv)')
244-
print(io, M.isupper?"\n super:":"\n sub:")
244+
print(io, M.isupper ? "\n super:" : "\n sub:")
245245
print_matrix(io, (M.ev)')
246246
end
247247

base/linalg/lapack.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ for (gels, gesv, getrs, getri, elty) in
867867
(Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt},
868868
Ptr{$elty}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt},
869869
Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}),
870-
&(btrn?'T':'N'), &m, &n, &size(B,2), A, &max(1,stride(A,2)),
870+
&(btrn ? 'T' : 'N'), &m, &n, &size(B,2), A, &max(1,stride(A,2)),
871871
B, &max(1,stride(B,2)), work, &lwork, info)
872872
chklapackerror(info[])
873873
if i == 1

base/linalg/triangular.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ end
372372
function copy!(A::T, B::T) where T<:Union{UpperTriangular,UnitUpperTriangular}
373373
n = size(B,1)
374374
for j = 1:n
375-
for i = 1:(isa(B, UnitUpperTriangular)?j-1:j)
375+
for i = 1:(isa(B, UnitUpperTriangular) ? j-1 : j)
376376
@inbounds A[i,j] = B[i,j]
377377
end
378378
end
@@ -381,7 +381,7 @@ end
381381
function copy!(A::T, B::T) where T<:Union{LowerTriangular,UnitLowerTriangular}
382382
n = size(B,1)
383383
for j = 1:n
384-
for i = (isa(B, UnitLowerTriangular)?j+1:j):n
384+
for i = (isa(B, UnitLowerTriangular) ? j+1 : j):n
385385
@inbounds A[i,j] = B[i,j]
386386
end
387387
end
@@ -394,7 +394,7 @@ function scale!(A::UpperTriangular, B::Union{UpperTriangular,UnitUpperTriangular
394394
if isa(B, UnitUpperTriangular)
395395
@inbounds A[j,j] = c
396396
end
397-
for i = 1:(isa(B, UnitUpperTriangular)?j-1:j)
397+
for i = 1:(isa(B, UnitUpperTriangular) ? j-1 : j)
398398
@inbounds A[i,j] = c * B[i,j]
399399
end
400400
end
@@ -406,7 +406,7 @@ function scale!(A::LowerTriangular, B::Union{LowerTriangular,UnitLowerTriangular
406406
if isa(B, UnitLowerTriangular)
407407
@inbounds A[j,j] = c
408408
end
409-
for i = (isa(B, UnitLowerTriangular)?j+1:j):n
409+
for i = (isa(B, UnitLowerTriangular) ? j+1 : j):n
410410
@inbounds A[i,j] = c * B[i,j]
411411
end
412412
end

base/pcre.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module PCRE
66

7-
include(string(length(Core.ARGS)>=2?Core.ARGS[2]:"","pcre_h.jl")) # include($BUILDROOT/base/pcre_h.jl)
7+
include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "pcre_h.jl")) # include($BUILDROOT/base/pcre_h.jl)
88

99
const PCRE_LIB = "libpcre2-8"
1010

0 commit comments

Comments
 (0)