Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature clang formatting #30

Merged
merged 5 commits into from
Jul 25, 2024
Merged

Feature clang formatting #30

merged 5 commits into from
Jul 25, 2024

Conversation

ewanwm
Copy link
Owner

@ewanwm ewanwm commented Jul 25, 2024

add git pre-commit hook to enforce uniform code formatting. Used microsoft for now (cause I like it) but could definitely change in future

Copy link
Contributor

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy reports: 144 concern(s)
  • tests/barger-propagator.hpp:3:10: warning: [modernize-deprecated-headers]

    inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead

    #include <math.h>
             ^~~~~~~~
             <cmath>
  • tests/barger-propagator.hpp:6:10: error: [clang-diagnostic-error]

    'nuTens/propagator/constants.hpp' file not found

    #include <nuTens/propagator/constants.hpp>
             ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:28:93: warning: 999.9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        inline void setParams(float m1, float m2, float theta, float baseline, float density = -999.9)
                                                                                                ^
  • tests/barger-propagator.hpp:38:18: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        inline float lv(float energy)
               ~~~~~ ^
               auto                   -> float
  • tests/barger-propagator.hpp:38:18: warning: [readability-make-member-function-const]

    method 'lv' can be made const

        inline float lv(float energy)
                     ^
                                      const
  • tests/barger-propagator.hpp:44:18: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        inline float lm()
               ~~~~~ ^
               auto       -> float
  • tests/barger-propagator.hpp:50:18: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        inline float calculateEffectiveAngle(float energy)
               ~~~~~ ^
               auto                                        -> float
  • tests/barger-propagator.hpp:52:28: warning: [readability-braces-around-statements]

    statement should be inside braces

            if (_density > 0.0)
                               ^
                                {
  • tests/barger-propagator.hpp:54:9: warning: [readability-else-after-return]

    do not use 'else' after 'return'

            else
            ^~~~
                        return _theta
  • tests/barger-propagator.hpp:54:13: warning: [readability-braces-around-statements]

    statement should be inside braces

            else
                ^
    note: this fix will not be applied because it overlaps with another fix
  • tests/barger-propagator.hpp:59:18: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        inline float calculateEffectiveDm2(float energy)
               ~~~~~ ^
               auto                                      -> float
  • tests/barger-propagator.hpp:61:28: warning: [readability-braces-around-statements]

    statement should be inside braces

            if (_density > 0.0)
                               ^
                                {
  • tests/barger-propagator.hpp:64:9: warning: [readability-else-after-return]

    do not use 'else' after 'return'

            else
            ^~~~
                        return (_m1 * _m1 - _m2 * _m2)
  • tests/barger-propagator.hpp:64:13: warning: [readability-braces-around-statements]

    statement should be inside braces

            else
                ^
    note: this fix will not be applied because it overlaps with another fix
  • tests/barger-propagator.hpp:69:18: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        inline float getPMNSelement(float energy, int alpha, int beta)
               ~~~~~ ^
               auto                                                    -> float
  • tests/barger-propagator.hpp:83:37: warning: [readability-braces-around-statements]

    statement should be inside braces

            if (alpha == 0 && beta == 0)
                                        ^
                                         {
  • tests/barger-propagator.hpp:84:13: warning: [bugprone-branch-clone]

    repeated branch in conditional chain

                return std::cos(gamma);
                ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:84:35: note: end of the original
                return std::cos(gamma);
                                      ^
    /home/runner/work/nuTens/nuTens/tests/barger-propagator.hpp:86:13: note: clone 1 starts here
                return std::cos(gamma);
                ^
  • tests/barger-propagator.hpp:85:9: warning: [readability-else-after-return]

    do not use 'else' after 'return'

            else if (alpha == 1 && beta == 1)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • tests/barger-propagator.hpp:85:42: warning: [readability-braces-around-statements]

    statement should be inside braces

            else if (alpha == 1 && beta == 1)
                                             ^
    note: this fix will not be applied because it overlaps with another fix
  • tests/barger-propagator.hpp:87:42: warning: [readability-braces-around-statements]

    statement should be inside braces

            else if (alpha == 0 && beta == 1)
                                             ^
    note: this fix will not be applied because it overlaps with another fix
  • tests/barger-propagator.hpp:89:42: warning: [readability-braces-around-statements]

    statement should be inside braces

            else if (alpha == 1 && beta == 0)
                                             ^
    note: this fix will not be applied because it overlaps with another fix
  • tests/barger-propagator.hpp:101:18: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        inline float calculateProb(float energy, int alpha, int beta)
               ~~~~~ ^
               auto                                                   -> float
  • tests/barger-propagator.hpp:126:27: warning: [readability-braces-around-statements]

    statement should be inside braces

            if (alpha == beta)
                              ^
                               {
  • tests/barger-propagator.hpp:128:9: warning: [readability-else-after-return]

    do not use 'else' after 'return'

            else
            ^~~~
                        return offAxis
  • tests/barger-propagator.hpp:128:13: warning: [readability-braces-around-statements]

    statement should be inside braces

            else
                ^
    note: this fix will not be applied because it overlaps with another fix
  • tests/test-utils.hpp:3:10: warning: [modernize-deprecated-headers]

    inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead

    #include <math.h>
             ^~~~~~~~
             <cmath>
  • tests/test-utils.hpp:14:7: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

    float relativeDiff(float f1, float f2)
    ~~~~~ ^
    auto                                   -> float
  • tests/test-utils.hpp:28:9: warning: [cppcoreguidelines-macro-usage]

    function-like macro 'TEST_EXPECTED' used; consider a 'constexpr' template function

    #define TEST_EXPECTED(value, expectation, varName, threshold)                                                          \
            ^
  • tests/test-utils.hpp:30:57: warning: [bugprone-macro-parentheses]

    macro argument should be enclosed in parentheses

            if (Testing::relativeDiff(value, expectation) > threshold)                                                     \
                                                            ^
                                                            (        )
  • tests/test-utils.hpp:32:36: warning: [bugprone-macro-parentheses]

    macro argument should be enclosed in parentheses

                std::cerr << "bad " << varName << std::endl;                                                               \
                                       ^
                                       (      )
  • tests/test-utils.hpp:33:37: warning: [bugprone-macro-parentheses]

    macro argument should be enclosed in parentheses

                std::cerr << "Got: " << value;                                                                             \
                                        ^
                                        (    )
  • tests/test-utils.hpp:34:44: warning: [bugprone-macro-parentheses]

    macro argument should be enclosed in parentheses

                std::cerr << "; Expected: " << expectation;                                                                \
                                               ^
                                               (          )
  • nuTens/logging.hpp:12:9: warning: [cppcoreguidelines-macro-usage]

    macro 'NT_LOG_LEVEL_TRACE' used to declare a constant; consider using a 'constexpr' constant

    #define NT_LOG_LEVEL_TRACE 0
            ^
  • nuTens/logging.hpp:13:9: warning: [cppcoreguidelines-macro-usage]

    macro 'NT_LOG_LEVEL_DEBUG' used to declare a constant; consider using a 'constexpr' constant

    #define NT_LOG_LEVEL_DEBUG 1
            ^
  • nuTens/logging.hpp:14:9: warning: [cppcoreguidelines-macro-usage]

    macro 'NT_LOG_LEVEL_INFO' used to declare a constant; consider using a 'constexpr' constant

    #define NT_LOG_LEVEL_INFO 2
            ^
  • nuTens/logging.hpp:15:9: warning: [cppcoreguidelines-macro-usage]

    macro 'NT_LOG_LEVEL_WARNING' used to declare a constant; consider using a 'constexpr' constant

    #define NT_LOG_LEVEL_WARNING 3
            ^
  • nuTens/logging.hpp:16:9: warning: [cppcoreguidelines-macro-usage]

    macro 'NT_LOG_LEVEL_ERROR' used to declare a constant; consider using a 'constexpr' constant

    #define NT_LOG_LEVEL_ERROR 4
            ^
  • nuTens/logging.hpp:17:9: warning: [cppcoreguidelines-macro-usage]

    macro 'NT_LOG_LEVEL_SILENT' used to declare a constant; consider using a 'constexpr' constant

    #define NT_LOG_LEVEL_SILENT 5
            ^
  • nuTens/logging.hpp:21:9: warning: [cppcoreguidelines-macro-usage]

    macro 'SPDLOG_ACTIVE_LEVEL' used to declare a constant; consider using a 'constexpr' constant

    #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
            ^
  • nuTens/logging.hpp:41:10: error: [clang-diagnostic-error]

    'spdlog/spdlog.h' file not found

    #include "spdlog/spdlog.h"
             ^
  • nuTens/logging.hpp:48:34: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'runtimeLogLevel' is non-const and globally accessible, consider making it const

    static spdlog::level::level_enum runtimeLogLevel = spdlog::level::trace;
                                     ^
  • nuTens/logging.hpp:67:23: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'once' is non-const and globally accessible, consider making it const

    static std::once_flag once;
                          ^
  • nuTens/logging.hpp:84:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_TRACE' used; consider using a 'constexpr' variadic template function

    #define NT_TRACE(...)                                                                                                  \
            ^
  • nuTens/logging.hpp:92:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_DEBUG' used; consider using a 'constexpr' variadic template function

    #define NT_DEBUG(...)                                                                                                  \
            ^
  • nuTens/logging.hpp:100:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_INFO' used; consider using a 'constexpr' variadic template function

    #define NT_INFO(...)                                                                                                   \
            ^
  • nuTens/logging.hpp:108:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_WARN' used; consider using a 'constexpr' variadic template function

    #define NT_WARN(...)                                                                                                   \
            ^
  • nuTens/logging.hpp:116:9: warning: [cppcoreguidelines-macro-usage]

    variadic macro 'NT_ERROR' used; consider using a 'constexpr' variadic template function

    #define NT_ERROR(...)                                                                                                  \
            ^
  • nuTens/nuTens-pch.hpp:3:10: warning: [modernize-deprecated-headers]

    inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead

    #include <math.h>
             ^~~~~~~~
             <cmath>
  • nuTens/nuTens-pch.hpp:9:10: error: [clang-diagnostic-error]

    'nuTens/logging.hpp' file not found

    #include <nuTens/logging.hpp>
             ^
  • nuTens/tensors/tensor.hpp:7:10: error: [clang-diagnostic-error]

    'nuTens/tensors/dtypes.hpp' file not found

    #include <nuTens/tensors/dtypes.hpp>
             ^
  • nuTens/tensors/tensor.hpp:47:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &ones(int length, NTdtypes::scalarType type, NTdtypes::deviceType device = NTdtypes::kCPU,
        ~~~~~~~~^
        auto 
  • nuTens/tensors/tensor.hpp:52:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &ones(const std::vector<long int> &shape, NTdtypes::scalarType type,
        ~~~~~~~~^
        auto 
  • nuTens/tensors/tensor.hpp:58:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &zeros(int length, NTdtypes::scalarType type, NTdtypes::deviceType device = NTdtypes::kCPU,
        ~~~~~~~~^
        auto 
  • nuTens/tensors/tensor.hpp:63:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &zeros(const std::vector<long int> &shape, NTdtypes::scalarType type,
        ~~~~~~~~^
        auto 
  • nuTens/tensors/tensor.hpp:71:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &dType(NTdtypes::scalarType type);
        ~~~~~~~~^
        auto                                     -> Tensor &
  • nuTens/tensors/tensor.hpp:73:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &device(NTdtypes::deviceType device);
        ~~~~~~~~^
        auto                                        -> Tensor &
  • nuTens/tensors/tensor.hpp:75:13: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor &requiresGrad(bool reqGrad);
        ~~~~~~~~^
        auto                               -> Tensor &
  • nuTens/tensors/tensor.hpp:87:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor matmul(const Tensor &t1, const Tensor &t2);
               ~~~~~~ ^
               auto                                              -> Tensor
  • nuTens/tensors/tensor.hpp:92:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor outer(const Tensor &t1, const Tensor &t2);
               ~~~~~~ ^
               auto                                             -> Tensor
  • nuTens/tensors/tensor.hpp:97:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor mul(const Tensor &t1, const Tensor &t2);
               ~~~~~~ ^
               auto                                           -> Tensor
  • nuTens/tensors/tensor.hpp:102:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor div(const Tensor &t1, const Tensor &t2);
               ~~~~~~ ^
               auto                                           -> Tensor
  • nuTens/tensors/tensor.hpp:107:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor pow(const Tensor &t, float s);
               ~~~~~~ ^
               auto                                 -> Tensor
  • nuTens/tensors/tensor.hpp:111:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor pow(const Tensor &t, std::complex<float> s);
               ~~~~~~ ^
               auto                                               -> Tensor
  • nuTens/tensors/tensor.hpp:115:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor exp(const Tensor &t);
               ~~~~~~ ^
               auto                        -> Tensor
  • nuTens/tensors/tensor.hpp:121:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor transpose(const Tensor &t, int dim1, int dim2);
               ~~~~~~ ^
               auto                                                  -> Tensor
  • nuTens/tensors/tensor.hpp:126:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor scale(const Tensor &t, float s);
               ~~~~~~ ^
               auto                                   -> Tensor
  • nuTens/tensors/tensor.hpp:130:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor scale(const Tensor &t, std::complex<float> s);
               ~~~~~~ ^
               auto                                                 -> Tensor
  • nuTens/tensors/tensor.hpp:187:10: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        bool operator==(const Tensor &rhs) const;
        ~~~~ ^
        auto                                     -> bool
  • nuTens/tensors/tensor.hpp:188:10: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        bool operator!=(const Tensor &rhs) const;
        ~~~~ ^
        auto                                     -> bool
  • nuTens/tensors/tensor.hpp:189:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor operator+(const Tensor &rhs) const;
        ~~~~~~ ^
        auto                                      -> Tensor
  • nuTens/tensors/tensor.hpp:190:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor operator-(const Tensor &rhs) const;
        ~~~~~~ ^
        auto                                      -> Tensor
  • nuTens/tensors/tensor.hpp:191:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor operator-() const;
        ~~~~~~ ^
        auto                     -> Tensor
  • nuTens/tensors/tensor.hpp:195:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor real() const;
        ~~~~~~ ^
        auto                -> Tensor
  • nuTens/tensors/tensor.hpp:197:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor imag() const;
        ~~~~~~ ^
        auto                -> Tensor
  • nuTens/tensors/tensor.hpp:200:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor conj() const;
        ~~~~~~ ^
        auto                -> Tensor
  • nuTens/tensors/tensor.hpp:202:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor abs() const;
        ~~~~~~ ^
        auto               -> Tensor
  • nuTens/tensors/tensor.hpp:204:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor angle() const;
        ~~~~~~ ^
        auto                 -> Tensor
  • nuTens/tensors/tensor.hpp:208:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor cumsum(int dim) const;
        ~~~~~~ ^
        auto                         -> Tensor
  • nuTens/tensors/tensor.hpp:211:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor sum() const;
        ~~~~~~ ^
        auto               -> Tensor
  • nuTens/tensors/tensor.hpp:222:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor grad() const;
        ~~~~~~ ^
        auto                -> Tensor
  • nuTens/tensors/tensor.hpp:231:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor sin(const Tensor &t);
               ~~~~~~ ^
               auto                        -> Tensor
  • nuTens/tensors/tensor.hpp:235:19: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static Tensor cos(const Tensor &t);
               ~~~~~~ ^
               auto                        -> Tensor
  • nuTens/tensors/tensor.hpp:241:26: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        friend std::ostream &operator<<(std::ostream &stream, const Tensor &tensor)
               ~~~~~~~~~~~~~~^
               auto                                                                 -> std::ostream &
  • nuTens/tensors/tensor.hpp:247:17: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        std::string toString() const;
        ~~~~~~~~~~~ ^
        auto                         -> std::string
  • nuTens/tensors/tensor.hpp:253:19: warning: [readability-avoid-const-params-in-decls]

    parameter 1 is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

        void setValue(const std::vector<std::variant<int, std::string>> &indices, const Tensor &value);
                      ^
  • nuTens/tensors/tensor.hpp:259:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor getValue(const std::vector<std::variant<int, std::string>> &indices) const;
        ~~~~~~ ^
        auto                                                                              -> Tensor
  • nuTens/tensors/tensor.hpp:259:21: warning: [readability-avoid-const-params-in-decls]

    parameter 1 is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

        Tensor getValue(const std::vector<std::variant<int, std::string>> &indices) const;
                        ^
  • nuTens/tensors/tensor.hpp:262:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        size_t getNdim() const;
        ~~~~~~ ^
        auto                   -> size_t
  • nuTens/tensors/tensor.hpp:265:9: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        int getBatchDim() const;
        ~~~ ^
        auto                    -> int
  • nuTens/tensors/tensor.hpp:268:22: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        std::vector<int> getShape() const;
                         ^
  • nuTens/tensors/tensor.hpp:293:24: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        static std::string getTensorLibrary();
               ~~~~~~~~~~~ ^
               auto                           -> std::string
  • nuTens/propagator/base-matter-solver.hpp:3:10: error: [clang-diagnostic-error]

    'nuTens/tensors/tensor.hpp' file not found

    #include <nuTens/tensors/tensor.hpp>
             ^
  • nuTens/propagator/propagator.hpp:4:10: error: [clang-diagnostic-error]

    'nuTens/propagator/base-matter-solver.hpp' file not found

    #include <nuTens/propagator/base-matter-solver.hpp>
             ^
  • nuTens/propagator/propagator.hpp:30:5: warning: [cppcoreguidelines-pro-type-member-init]

    constructor does not initialize these fields: _PMNSmatrix, _masses, _matterSolver

        Propagator(int nGenerations, float baseline) : _baseline(baseline), _nGenerations(nGenerations){};
        ^
  • nuTens/propagator/propagator.hpp:34:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor calculateProbs(const Tensor &energies) const;
               ^
  • nuTens/propagator/propagator.hpp:98:12: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

        Tensor _calculateProbs(const Tensor &energies, const Tensor &masses, const Tensor &PMNS) const;
               ^
  • nuTens/propagator/propagator.hpp:100:3: warning: [readability-redundant-access-specifiers]

    redundant access specifier has the same accessibility as the previous access specifier

      private:
      ^~~~~~~~
  • nuTens/propagator/propagator.hpp:101:12: warning: [bugprone-reserved-identifier]

    declaration uses identifier '_PMNSmatrix', which is a reserved identifier

        Tensor _PMNSmatrix;
               ^~~~~~~~~~~
               PMNSmatrix
  • nuTens/propagator/const-density-solver.hpp:3:10: error: [clang-diagnostic-error]

    'nuTens/propagator/base-matter-solver.hpp' file not found

    #include <nuTens/propagator/base-matter-solver.hpp>
             ^
  • nuTens/propagator/const-density-solver.hpp:35:5: warning: [cppcoreguidelines-pro-type-member-init]

    constructor does not initialize these fields: PMNS, masses, diagMassMatrix, electronOuter

        ConstDensityMatterSolver(int nGenerations, float density) : nGenerations(nGenerations), density(density)
        ^
  • nuTens/propagator/const-density-solver.hpp:57:17: warning: [readability-make-member-function-const]

    method 'setMasses' can be made const

        inline void setMasses(const Tensor &newMasses)
                    ^
                                                       const
  • nuTens/propagator/const-density-solver.hpp:65:19: warning: [cppcoreguidelines-init-variables]

    variable 'm_i' is not initialized

                float m_i = masses.getValue<float>({0, i});
                      ^
                          = NAN
  • tests/two-flavour-const-matter.cpp:1:10: error: [clang-diagnostic-error]

    'nuTens/propagator/const-density-solver.hpp' file not found

    #include <nuTens/propagator/const-density-solver.hpp>
             ^
  • tests/two-flavour-const-matter.cpp:7:5: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

    int main()
    ~~~ ^
    auto       -> int
  • tests/two-flavour-const-matter.cpp:9:5: warning: [readability-isolate-declaration]

    multiple declarations in a single statement reduces readability

        float m1 = 1.0, m2 = 2.0;
        ^~~~~~~~~~~~~~~~~~~~~~~~~
  • tests/two-flavour-const-matter.cpp:14:12: warning: [cppcoreguidelines-init-variables]

    variable 'masses' is not initialized

        Tensor masses;
               ^
                      = 0
  • tests/two-flavour-const-matter.cpp:20:12: warning: [cppcoreguidelines-init-variables]

    variable 'energies' is not initialized

        Tensor energies;
               ^
                        = 0
  • tests/two-flavour-const-matter.cpp:27:30: warning: [cppcoreguidelines-init-variables]

    variable 'tensorSolver' is not initialized

        ConstDensityMatterSolver tensorSolver(2, density);
                                 ^
                                              = 0
  • tests/two-flavour-const-matter.cpp:31:22: warning: [cppcoreguidelines-init-variables]

    variable 'bargerProp' is not initialized

        TwoFlavourBarger bargerProp;
                         ^
                                    = 0
  • tests/two-flavour-const-matter.cpp:37:15: warning: [cppcoreguidelines-init-variables]

    variable 'theta' is not initialized

            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                  ^
                        = NAN
  • tests/two-flavour-const-matter.cpp:42:16: warning: [cppcoreguidelines-init-variables]

    variable 'PMNS' is not initialized

            Tensor PMNS;
                   ^
                        = 0
  • tests/two-flavour-const-matter.cpp:53:16: warning: [cppcoreguidelines-init-variables]

    variable 'eigenVals' is not initialized

            Tensor eigenVals, eigenVecs;
                   ^
                             = 0
  • tests/two-flavour-const-matter.cpp:62:15: warning: [cppcoreguidelines-init-variables]

    variable 'calcV1' is not initialized

            float calcV1 = eigenVals.getValue<float>({0, 0});
                  ^
                         = NAN
  • tests/two-flavour-const-matter.cpp:63:15: warning: [cppcoreguidelines-init-variables]

    variable 'calcV2' is not initialized

            float calcV2 = eigenVals.getValue<float>({0, 1});
                  ^
                         = NAN
  • tests/barger.cpp:2:10: error: [clang-diagnostic-error]

    'tests/barger-propagator.hpp' file not found

    #include <tests/barger-propagator.hpp>
             ^
  • tests/barger.cpp:9:5: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

    int main()
    ~~~ ^
    auto       -> int
  • tests/barger.cpp:13:22: warning: [cppcoreguidelines-init-variables]

    variable 'bargerProp' is not initialized

        TwoFlavourBarger bargerProp;
                         ^
                                    = 0
  • tests/tensor-basic.cpp:2:10: error: [clang-diagnostic-error]

    'nuTens/tensors/dtypes.hpp' file not found

    #include <nuTens/tensors/dtypes.hpp>
             ^
  • tests/tensor-basic.cpp:10:5: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

    int main()
    ~~~ ^
    auto       -> int
  • tests/tensor-basic.cpp:16:12: warning: [cppcoreguidelines-init-variables]

    variable 'tensorFloat' is not initialized

        Tensor tensorFloat;
               ^
                           = 0
  • tests/tensor-basic.cpp:33:12: warning: [cppcoreguidelines-init-variables]

    variable 'realSquared' is not initialized

        Tensor realSquared = Tensor::matmul(tensorFloat, tensorFloat);
               ^
                           = 0
  • tests/tensor-basic.cpp:40:12: warning: [cppcoreguidelines-init-variables]

    variable 'tensorComplex' is not initialized

        Tensor tensorComplex;
               ^
                             = 0
  • tests/tensor-basic.cpp:69:12: warning: [cppcoreguidelines-init-variables]

    variable 'imagSquared' is not initialized

        Tensor imagSquared = Tensor::matmul(tensorComplex, tensorComplex);
               ^
                           = 0
  • tests/tensor-basic.cpp:84:12: warning: [cppcoreguidelines-init-variables]

    variable 'ones' is not initialized

        Tensor ones;
               ^
                    = 0
  • tests/tensor-basic.cpp:86:12: warning: [cppcoreguidelines-init-variables]

    variable 'twos' is not initialized

        Tensor twos = ones + ones;
               ^
                    = 0
  • tests/tensor-basic.cpp:103:12: warning: [cppcoreguidelines-init-variables]

    variable 'ones_scaleTest' is not initialized

        Tensor ones_scaleTest;
               ^
                              = 0
  • tests/tensor-basic.cpp:105:12: warning: [cppcoreguidelines-init-variables]

    variable 'threes' is not initialized

        Tensor threes = Tensor::scale(ones_scaleTest, 3.0).sum();
               ^
                      = 0
  • tests/tensor-basic.cpp:107:12: warning: [cppcoreguidelines-init-variables]

    variable 'grad' is not initialized

        Tensor grad = ones_scaleTest.grad();
               ^
                    = 0
  • tests/tensor-basic.cpp:120:12: warning: [cppcoreguidelines-init-variables]

    variable 'complexGradTest' is not initialized

        Tensor complexGradTest;
               ^
                               = 0
  • tests/tensor-basic.cpp:128:12: warning: [cppcoreguidelines-init-variables]

    variable 'complexGradSquared' is not initialized

        Tensor complexGradSquared = Tensor::matmul(complexGradTest, complexGradTest).sum();
               ^
                                  = 0
  • tests/two-flavour-vacuum.cpp:1:10: error: [clang-diagnostic-error]

    'nuTens/propagator/propagator.hpp' file not found

    #include <nuTens/propagator/propagator.hpp>
             ^
  • tests/two-flavour-vacuum.cpp:7:5: warning: [modernize-use-trailing-return-type]

    use a trailing return type for this function

    int main()
    ~~~ ^
    auto       -> int
  • tests/two-flavour-vacuum.cpp:9:5: warning: [readability-isolate-declaration]

    multiple declarations in a single statement reduces readability

        float m1 = 0.1, m2 = 0.5;
        ^~~~~~~~~~~~~~~~~~~~~~~~~
  • tests/two-flavour-vacuum.cpp:13:12: warning: [cppcoreguidelines-init-variables]

    variable 'masses' is not initialized

        Tensor masses;
               ^
                      = 0
  • tests/two-flavour-vacuum.cpp:19:12: warning: [cppcoreguidelines-init-variables]

    variable 'energies' is not initialized

        Tensor energies;
               ^
                        = 0
  • tests/two-flavour-vacuum.cpp:24:16: warning: [cppcoreguidelines-init-variables]

    variable 'tensorPropagator' is not initialized

        Propagator tensorPropagator(2, baseline);
                   ^
                                    = 0
  • tests/two-flavour-vacuum.cpp:28:22: warning: [cppcoreguidelines-init-variables]

    variable 'bargerProp' is not initialized

        TwoFlavourBarger bargerProp;
                         ^
                                    = 0
  • tests/two-flavour-vacuum.cpp:34:15: warning: [cppcoreguidelines-init-variables]

    variable 'theta' is not initialized

            float theta = (-1.0 + 2.0 * (float)i / 20.0) * 0.49 * M_PI;
                  ^
                        = NAN
  • tests/two-flavour-vacuum.cpp:39:16: warning: [cppcoreguidelines-init-variables]

    variable 'PMNS' is not initialized

            Tensor PMNS;
                   ^
                        = 0
  • tests/two-flavour-vacuum.cpp:49:16: warning: [cppcoreguidelines-init-variables]

    variable 'probabilities' is not initialized

            Tensor probabilities = tensorPropagator.calculateProbs(energies);
                   ^
                                 = 0
  • nuTens/tensors/torch-tensor.cpp:2:10: error: [clang-diagnostic-error]

    'nuTens/tensors/tensor.hpp' file not found

    #include <nuTens/tensors/tensor.hpp>
             ^
  • nuTens/tensors/torch-tensor.cpp:5:49: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'scalarTypeMap' is non-const and globally accessible, consider making it const

    std::map<NTdtypes::scalarType, c10::ScalarType> scalarTypeMap = {{NTdtypes::kFloat, torch::kFloat},
                                                    ^
  • nuTens/tensors/torch-tensor.cpp:11:49: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'deviceTypeMap' is non-const and globally accessible, consider making it const

    std::map<NTdtypes::deviceType, c10::DeviceType> deviceTypeMap = {{NTdtypes::kCPU, torch::kCPU},
                                                    ^
  • nuTens/propagator/propagator.cpp:1:10: error: [clang-diagnostic-error]

    'nuTens/propagator/propagator.hpp' file not found

    #include <nuTens/propagator/propagator.hpp>
             ^
  • nuTens/propagator/const-density-solver.cpp:1:10: error: [clang-diagnostic-error]

    'nuTens/propagator/const-density-solver.hpp' file not found

    #include <nuTens/propagator/const-density-solver.hpp>
             ^

Have any feedback or feature suggestions? Share it here.

@ewanwm ewanwm merged commit b356bfe into main Jul 25, 2024
2 checks passed
@ewanwm ewanwm deleted the feature_clang_formatting branch July 25, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant