Skip to content

Commit

Permalink
changes for sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
realHannes committed Jun 14, 2024
1 parent 36473c4 commit 3219c66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ IntDoubleStr ToNumericValueGetter::operator()(
}

// ____________________________________________________________________________
OptIri makeDatatypeValueGetter::iriFromLiteral(const std::string& str) const {
inline OptIri makeDatatypeValueGetter::iriFromLiteral(
const std::string& str) const {
// check that we return an Iri w.r.t. Literals
if (!(str.starts_with("\"") || str.starts_with("'"))) {
return std::nullopt;
Expand All @@ -191,40 +192,41 @@ OptIri makeDatatypeValueGetter::iriFromLiteral(const std::string& str) const {
// ____________________________________________________________________________
OptIri makeDatatypeValueGetter::operator()(
ValueId id, const EvaluationContext* context) const {
using enum Datatype;
auto datatype = id.getDatatype();
std::optional<std::string> entity;
switch (datatype) {
case Datatype::Bool:
case Bool:
return Iri::fromIri(XSD_BOOLEAN_TYPE);
case Datatype::Double:
case Double:
return Iri::fromIri(XSD_DOUBLE_TYPE);
case Datatype::Int:
case Int:
return Iri::fromIri(XSD_INT_TYPE);
case Datatype::Date: {
case Date: {
auto dateType = id.getDate().toStringAndType().second;
if (dateType != nullptr) {
return Iri::fromIri(dateType);
} else {
return std::nullopt;
}

Check warning on line 211 in src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp#L210-L211

Added lines #L210 - L211 were not covered by tests
}
case Datatype::LocalVocabIndex: {
case LocalVocabIndex: {
const auto& voc = context->_localVocab;
return iriFromLiteral(
voc.getWord(id.getLocalVocabIndex()).toStringRepresentation());

Check warning on line 216 in src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp#L214-L216

Added lines #L214 - L216 were not covered by tests
}
case Datatype::VocabIndex: {
case VocabIndex: {
const auto& idx = context->_qec.getIndex();
entity = idx.idToOptionalString(id.getVocabIndex());

Check warning on line 220 in src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp#L219-L220

Added lines #L219 - L220 were not covered by tests
if (!entity.has_value()) {
return std::nullopt;
}
return iriFromLiteral(entity.value());
}

Check warning on line 225 in src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/sparqlExpressions/SparqlExpressionValueGetters.cpp#L222-L225

Added lines #L222 - L225 were not covered by tests
case Datatype::Undefined:
case Datatype::BlankNodeIndex:
case Datatype::TextRecordIndex:
case Datatype::WordVocabIndex:
case Undefined:
case BlankNodeIndex:
case TextRecordIndex:
case WordVocabIndex:
return std::nullopt;
}
AD_FAIL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct makeDatatypeValueGetter : Mixin<makeDatatypeValueGetter> {
const EvaluationContext* context) const;
// Helper function to retrieve Iri from LiteralOrIri-Content-String
// if an actual Literal was contained.
inline OptIri iriFromLiteral(const std::string& str) const;
OptIri iriFromLiteral(const std::string& str) const;
};

// `IriValueGetter` returns an
Expand Down

0 comments on commit 3219c66

Please sign in to comment.