Skip to content

Commit

Permalink
fix according to sonarlint
Browse files Browse the repository at this point in the history
  • Loading branch information
luk036 committed Aug 28, 2023
1 parent a14bf3c commit f89a5aa
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 62 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/
# target:
add_library(${PROJECT_NAME} INTERFACE)

# set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
# set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)

# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(${PROJECT_NAME} INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
Expand Down
7 changes: 0 additions & 7 deletions include/projgeom/ck_plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ namespace fun {
const auto t1 = altitude(a1, a2.meet(a3));
const auto t2 = altitude(a2, a3.meet(a1));
return t1.meet(t2);
// return {a2.meet(a3), a1.meet(a3), a1.meet(a2)};
}

/**
Expand Down Expand Up @@ -82,10 +81,4 @@ namespace fun {
return involution(mirror.perp(), mirror, pt_p);
}

/*
axiom(Point pt_p, Point pt_q, Point pt_r, Line ln_l) {
ln_l == Line{pt_p, pt_q} => I(pt_p, ln_l) and I(pt_q, ln_l);
}
*/

} // namespace fun
4 changes: 2 additions & 2 deletions include/projgeom/ell_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class EllipticLine : public PgObject<EllipticLine, EllipticPoint> {
*
* @return EllipticLine
*/
inline constexpr auto EllipticPoint::perp() const -> EllipticLine {
constexpr auto EllipticPoint::perp() const -> EllipticLine {
return EllipticLine{this->coord};
}

Expand All @@ -64,6 +64,6 @@ inline constexpr auto EllipticPoint::perp() const -> EllipticLine {
*
* @return EllipticPoint
*/
inline constexpr auto EllipticLine::perp() const -> EllipticPoint {
constexpr auto EllipticLine::perp() const -> EllipticPoint {
return EllipticPoint{this->coord};
}
22 changes: 11 additions & 11 deletions include/projgeom/euclid_plane_measure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace fun {
* @param[in] z2
* @return auto
*/
template <typename K> requires Integral<K> inline constexpr auto quad1(const K &x1, const K &z1,
template <typename K> requires Integral<K> constexpr auto quad1(const K &x1, const K &z1,
const K &x2,
const K &z2) {
return sq(Fraction<K>(x1, z1) - Fraction<K>(x2, z2));
Expand All @@ -33,7 +33,7 @@ namespace fun {
*/
template <typename K>
// requires (!Integral<K>)
inline constexpr auto quad1(const K &x1, const K &z1, const K &x2, const K &z2) {
constexpr auto quad1(const K &x1, const K &z1, const K &x2, const K &z2) {
return sq(x1 / z1 - x2 / z2);
}

Expand All @@ -45,11 +45,11 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Point>
inline constexpr auto quadrance(const Point &a1, const Point &a2) {
constexpr auto quadrance(const Point &a1, const Point &a2) {
return quad1(a1[0], a1[2], a2[0], a2[2]) + quad1(a1[1], a1[2], a2[1], a2[2]);
}

template <typename... Args> inline constexpr auto quadrance_copy(const Args &... args) {
template <typename... Args> constexpr auto quadrance_copy(const Args &... args) {
return std::make_tuple(quadrance(args.first, args.second)...);
}

Expand All @@ -67,7 +67,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Line, typename T>
inline constexpr auto sbase(const Line &l1, const Line &l2, const T &d) {
constexpr auto sbase(const Line &l1, const Line &l2, const T &d) {
using K = Value_type<Line>;
if constexpr (Integral<K>) {
return Fraction<K>(d, dot1(l1, l1)) * Fraction<K>(d, dot1(l2, l2));
Expand All @@ -84,7 +84,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Line>
inline constexpr auto spread(const Line &l1, const Line &l2) {
constexpr auto spread(const Line &l1, const Line &l2) {
return sbase(l1, l2, cross2(l1, l2));
}

Expand All @@ -95,7 +95,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Point>
inline constexpr auto tri_quadrance(const Triple<Point> &triangle) {
constexpr auto tri_quadrance(const Triple<Point> &triangle) {
const auto &[a1, a2, a3] = triangle;
return std::array{quadrance(a2, a3), quadrance(a1, a3), quadrance(a1, a2)};
}
Expand All @@ -107,7 +107,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Line>
inline constexpr auto tri_spread(const Triple<Line> &trilateral) {
constexpr auto tri_spread(const Triple<Line> &trilateral) {
const auto &[a1, a2, a3] = trilateral;
return std::array{spread(a2, a3), spread(a1, a3), spread(a1, a2)};
}
Expand All @@ -120,7 +120,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Line>
inline constexpr auto cross_s(const Line &l1, const Line &l2) {
constexpr auto cross_s(const Line &l1, const Line &l2) {
return sbase(l1, l2, dot1(l1, l2));
}

Expand All @@ -134,7 +134,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Point>
inline constexpr auto distance(const Point &a, const Point &b) {
constexpr auto distance(const Point &a, const Point &b) {
return std::sqrt(double(quadrance(a, b)));
}

Expand All @@ -146,7 +146,7 @@ namespace fun {
* @return auto
*/
template <ProjectivePlaneCoord2 Line>
inline constexpr auto angle(const Line &line_l, const Line &line_m) {
constexpr auto angle(const Line &line_l, const Line &line_m) {
return std::asin(std::sqrt(double(spread(line_l, line_m))));
}

Expand Down
12 changes: 4 additions & 8 deletions include/projgeom/fractions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace fun {
* @param[in] a
* @return T
*/
template <typename T> inline constexpr auto abs(const T &a) -> T {
template <typename T> constexpr auto abs(const T &a) -> T {
if constexpr (std::is_unsigned_v<T>) {
return a;
} else {
Expand All @@ -38,7 +38,7 @@ namespace fun {
* @param[in] __n
* @return _Mn
*/
template <Integral _Mn> inline constexpr auto gcd_recur(const _Mn &__m, const _Mn &__n) -> _Mn {
template <Integral _Mn> constexpr auto gcd_recur(const _Mn &__m, const _Mn &__n) -> _Mn {
if (__n == 0) {
return abs(__m);
}
Expand All @@ -53,7 +53,7 @@ namespace fun {
* @param[in] __n
* @return _Mn
*/
template <Integral _Mn> inline constexpr auto gcd(const _Mn &__m, const _Mn &__n) -> _Mn {
template <Integral _Mn> constexpr auto gcd(const _Mn &__m, const _Mn &__n) -> _Mn {
if (__m == 0) {
return abs(__n);
}
Expand All @@ -68,7 +68,7 @@ namespace fun {
* @param[in] __n
* @return _Mn
*/
template <Integral _Mn> inline constexpr auto lcm(const _Mn &__m, const _Mn &__n) -> _Mn {
template <Integral _Mn> constexpr auto lcm(const _Mn &__m, const _Mn &__n) -> _Mn {
if (__m == 0 || __n == 0) {
return 0;
}
Expand Down Expand Up @@ -712,8 +712,4 @@ namespace fun {
return os;
}
};

// For template deduction
// Integral{Z} Fraction(const Z &, const Z &) noexcept -> Fraction<Z>;

} // namespace fun
8 changes: 4 additions & 4 deletions include/projgeom/fractions.hpp.bak
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace fun {
* @param[in] a
* @return T
*/
template <typename T> inline constexpr auto abs(const T& a) -> T {
template <typename T> constexpr auto abs(const T& a) -> T {
if constexpr (std::is_unsigned_v<T>) {
return a;
} else {
Expand All @@ -38,7 +38,7 @@ namespace fun {
* @param[in] __n
* @return _Mn
*/
template <Integral _Mn> inline constexpr auto gcd_recur(_Mn __m, _Mn __n) -> _Mn {
template <Integral _Mn> constexpr auto gcd_recur(_Mn __m, _Mn __n) -> _Mn {
if (__n == 0) {
return abs(__m);
}
Expand All @@ -53,7 +53,7 @@ namespace fun {
* @param[in] __n
* @return _Mn
*/
template <Integral _Mn> inline constexpr auto gcd(_Mn __m, _Mn __n) -> _Mn {
template <Integral _Mn> constexpr auto gcd(_Mn __m, _Mn __n) -> _Mn {
if (__m == 0) {
return abs(__n);
}
Expand All @@ -68,7 +68,7 @@ namespace fun {
* @param[in] __n
* @return _Mn
*/
template <Integral _Mn> inline constexpr auto lcm(_Mn __m, _Mn __n) -> _Mn {
template <Integral _Mn> constexpr auto lcm(_Mn __m, _Mn __n) -> _Mn {
if (__m == 0 || __n == 0) {
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions include/projgeom/hyp_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class HyperbolicLine : public PgObject<HyperbolicLine, HyperbolicPoint> {
*
* @return HyperbolicLine
*/
inline constexpr auto HyperbolicPoint::perp() const -> HyperbolicLine {
constexpr auto HyperbolicPoint::perp() const -> HyperbolicLine {
return HyperbolicLine({this->coord[0], this->coord[1], -this->coord[2]});
}

Expand All @@ -64,6 +64,6 @@ inline constexpr auto HyperbolicPoint::perp() const -> HyperbolicLine {
*
* @return HyperbolicPoint
*/
inline constexpr auto HyperbolicLine::perp() const -> HyperbolicPoint {
constexpr auto HyperbolicLine::perp() const -> HyperbolicPoint {
return HyperbolicPoint({this->coord[0], this->coord[1], -this->coord[2]});
}
4 changes: 2 additions & 2 deletions include/projgeom/myck_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MyCKLine : public PgObject<MyCKLine, MyCKPoint> {
*
* @return MyCKLine
*/
inline constexpr auto MyCKPoint::perp() const -> MyCKLine {
constexpr auto MyCKPoint::perp() const -> MyCKLine {
return MyCKLine({-2 * this->coord[0], this->coord[1], -2 * this->coord[2]});
}

Expand All @@ -64,6 +64,6 @@ inline constexpr auto MyCKPoint::perp() const -> MyCKLine {
*
* @return MyCKPoint
*/
inline constexpr auto MyCKLine::perp() const -> MyCKPoint {
constexpr auto MyCKLine::perp() const -> MyCKPoint {
return MyCKPoint({-this->coord[0], 2 * this->coord[1], -this->coord[2]});
}
2 changes: 1 addition & 1 deletion include/projgeom/pg_line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace fun {
};

/// Return meet of two lines.
template <Ring _K> inline constexpr auto meet(const pg_line<_K> &ln_l, const pg_line<_K> &ln_m)
template <Ring _K> constexpr auto meet(const pg_line<_K> &ln_l, const pg_line<_K> &ln_m)
-> pg_point<_K> {
return ln_l * ln_m;
}
Expand Down
28 changes: 14 additions & 14 deletions include/projgeom/pg_plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires ProjPlanePrimDual<Point, Line>
#endif
inline constexpr auto coincident(const Point &pt_p, const Point &pt_q, const Point &pt_r)
constexpr auto coincident(const Point &pt_p, const Point &pt_q, const Point &pt_r)
-> bool {
return pt_p.meet(pt_q).incident(pt_r);
}
Expand All @@ -53,19 +53,19 @@ namespace fun {
* @brief Check Pappus Theorem
*
* @tparam Point Point
* @param[in] co1
* @param[in] co2
* @param[in] coline1
* @param[in] coline2
* @return true
* @return false
*/
template <class Point, class Line = typename Point::Dual>
#if __cpp_concepts >= 201907L
requires ProjPlanePrimDual<Point, Line>
#endif
inline constexpr auto check_pappus(const std::array<Point, 3> &co1,
const std::array<Point, 3> &co2) -> bool {
const auto &[pt_a, pt_b, pt_c] = co1;
const auto &[pt_d, pt_e, pt_f] = co2;
constexpr auto check_pappus(const std::array<Point, 3> &coline1,
const std::array<Point, 3> &coline2) -> bool {
const auto &[pt_a, pt_b, pt_c] = coline1;
const auto &[pt_d, pt_e, pt_f] = coline2;
const auto pt_g = (pt_a.meet(pt_e)).meet(pt_b.meet(pt_d));
const auto pt_h = (pt_a.meet(pt_f)).meet(pt_c.meet(pt_d));
const auto pt_i = (pt_b.meet(pt_f)).meet(pt_c.meet(pt_e));
Expand All @@ -84,7 +84,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires ProjPlanePrimDual<Point, Line>
#endif
inline constexpr auto tri_dual(const std::array<Point, 3> &triangle)
constexpr auto tri_dual(const std::array<Point, 3> &triangle)
-> std::array<Line, 3> {
const auto &[a1, a2, a3] = triangle;
assert(!coincident(a1, a2, a3));
Expand All @@ -104,7 +104,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires ProjPlanePrimDual<Point, Line>
#endif
inline constexpr auto persp(const std::array<Point, 3> &tri1,
constexpr auto persp(const std::array<Point, 3> &tri1,
const std::array<Point, 3> &tri2) -> bool {
const auto &[pt_a, pt_b, pt_c] = tri1;
const auto &[pt_d, pt_e, pt_f] = tri2;
Expand All @@ -125,13 +125,13 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires ProjPlanePrimDual<Point, Line>
#endif
inline constexpr auto check_desargue(const std::array<Point, 3> &tri1,
constexpr auto check_desargue(const std::array<Point, 3> &tri1,
const std::array<Point, 3> &tri2) -> bool {
const auto trid1 = tri_dual(tri1);
const auto trid2 = tri_dual(tri2);
const auto bool1 = persp(tri1, tri2);
const auto b2 = persp(trid1, trid2);
return (bool1 && b2) || (!bool1 && !b2);
const auto bool2 = persp(trid1, trid2);
return (bool1 && bool2) || (!bool1 && !bool2);
}

/**
Expand Down Expand Up @@ -180,7 +180,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires ProjectivePlaneDual<Value, Point, Line>
#endif
inline constexpr auto harm_conj(const Point &pt_a, const Point &pt_b, const Point &pt_c)
constexpr auto harm_conj(const Point &pt_a, const Point &pt_b, const Point &pt_c)
-> Point {
assert(coincident(pt_a, pt_b, pt_c));
const auto ab = pt_a.meet(pt_b);
Expand All @@ -203,7 +203,7 @@ namespace fun {
#if __cpp_concepts >= 201907L
requires ProjectivePlaneDual<Value, Point, Line>
#endif
inline constexpr auto involution(const Point &origin, const Line &mirror, const Point &pt_p)
constexpr auto involution(const Point &origin, const Line &mirror, const Point &pt_p)
-> Point {
const auto po = pt_p.meet(origin);
const auto pt_b = po.meet(mirror);
Expand Down
2 changes: 1 addition & 1 deletion include/projgeom/pg_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace fun {
* @return pg_line<_K>
*/
template <Ring _K>
inline constexpr auto join(const pg_point<_K> &pt_p, const pg_point<_K> &pt_q) -> pg_line<_K> {
constexpr auto join(const pg_point<_K> &pt_p, const pg_point<_K> &pt_q) -> pg_line<_K> {
return pt_p * pt_q;
}

Expand Down
Loading

0 comments on commit f89a5aa

Please sign in to comment.