[clang-tidy] do not use return after else (#892)

Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2020-06-15 13:09:29 -07:00
committed by GitHub
parent 4dbfeb0bbc
commit a808c1f44a
5 changed files with 22 additions and 22 deletions

View File

@@ -10,8 +10,7 @@ void* BuildGraphOfNextDocument(Parser& parser,
GraphBuilderAdapter eventHandler(graphBuilder); GraphBuilderAdapter eventHandler(graphBuilder);
if (parser.HandleNextDocument(eventHandler)) { if (parser.HandleNextDocument(eventHandler)) {
return eventHandler.RootNode(); return eventHandler.RootNode();
} else {
return nullptr;
} }
return nullptr;
} }
} // namespace YAML } // namespace YAML

View File

@@ -94,15 +94,13 @@ EmitterNodeType::value EmitterState::NextGroupType(
if (type == GroupType::Seq) { if (type == GroupType::Seq) {
if (GetFlowType(type) == Block) if (GetFlowType(type) == Block)
return EmitterNodeType::BlockSeq; return EmitterNodeType::BlockSeq;
else return EmitterNodeType::FlowSeq;
return EmitterNodeType::FlowSeq;
} else {
if (GetFlowType(type) == Block)
return EmitterNodeType::BlockMap;
else
return EmitterNodeType::FlowMap;
} }
if (GetFlowType(type) == Block)
return EmitterNodeType::BlockMap;
return EmitterNodeType::FlowMap;
// can't happen // can't happen
assert(false); assert(false);
return EmitterNodeType::NoType; return EmitterNodeType::NoType;
@@ -156,9 +154,8 @@ void EmitterState::EndedGroup(GroupType::value type) {
if (m_groups.empty()) { if (m_groups.empty()) {
if (type == GroupType::Seq) { if (type == GroupType::Seq) {
return SetError(ErrorMsg::UNEXPECTED_END_SEQ); return SetError(ErrorMsg::UNEXPECTED_END_SEQ);
} else {
return SetError(ErrorMsg::UNEXPECTED_END_MAP);
} }
return SetError(ErrorMsg::UNEXPECTED_END_MAP);
} }
// get rid of the current group // get rid of the current group

View File

@@ -54,14 +54,16 @@ std::string Escape(Stream& in, int codeLength) {
// now break it up into chars // now break it up into chars
if (value <= 0x7F) if (value <= 0x7F)
return Str(value); return Str(value);
else if (value <= 0x7FF)
if (value <= 0x7FF)
return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F)); return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F));
else if (value <= 0xFFFF)
if (value <= 0xFFFF)
return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) +
Str(0x80 + (value & 0x3F)); Str(0x80 + (value & 0x3F));
else
return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) + return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) +
Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
} }
// Escape // Escape

View File

@@ -47,7 +47,8 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) {
if (INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) { if (INPUT.column() == 0 && Exp::DocIndicator().Matches(INPUT)) {
if (params.onDocIndicator == BREAK) { if (params.onDocIndicator == BREAK) {
break; break;
} else if (params.onDocIndicator == THROW) { }
if (params.onDocIndicator == THROW) {
throw ParserException(INPUT.mark(), ErrorMsg::DOC_IN_SCALAR); throw ParserException(INPUT.mark(), ErrorMsg::DOC_IN_SCALAR);
} }
} }

View File

@@ -350,7 +350,9 @@ void Stream::StreamInUtf16() const {
// Trailing (low) surrogate...ugh, wrong order // Trailing (low) surrogate...ugh, wrong order
QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER); QueueUnicodeCodepoint(m_readahead, CP_REPLACEMENT_CHARACTER);
return; return;
} else if (ch >= 0xD800 && ch < 0xDC00) { }
if (ch >= 0xD800 && ch < 0xDC00) {
// ch is a leading (high) surrogate // ch is a leading (high) surrogate
// Four byte UTF-8 code point // Four byte UTF-8 code point
@@ -375,11 +377,10 @@ void Stream::StreamInUtf16() const {
// Easiest case: queue the codepoint and return // Easiest case: queue the codepoint and return
QueueUnicodeCodepoint(m_readahead, ch); QueueUnicodeCodepoint(m_readahead, ch);
return; return;
} else {
// Start the loop over with the new high surrogate
ch = chLow;
continue;
} }
// Start the loop over with the new high surrogate
ch = chLow;
continue;
} }
// Select the payload bits from the high surrogate // Select the payload bits from the high surrogate