Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

AUTOSAR A7-1-3 - False positive on "const" qualifier

I'm using Parasoft C++Test Professional 2023.1 and I'm getting false positives on AUTOSAR Rule A7-1-3 which states that "CV-qualifiers shall be placed on the right hand side of the type that is a typedef or a using name"

Take this example:

#include <cstdint>
#include <typeinfo>
#include <iostream>
#include <string>

namespace Utils
{
   enum class UnitType : uint8_t
   {
      OK = 0,
      KO = 1,
   };

   class Test final
   {
      public:
         void setUnitTypeAAA(UnitType const type) noexcept
         {
            m_type = type;
         }

         void setUnitTypeBBB(const UnitType type) noexcept
         {
            m_type = type;
         }

         constexpr UnitType getType() const noexcept
         {
            return m_type;
         }

      private:
         UnitType m_type {UnitType::OK};
   };

}   // namespace Utils

The false positive happens on setUnitTypeAAA which has indeed const on the right hand side.

I understand that the rule checks only a "type that is a typedef or a using name" so I'm ok with setUnitTypeBBB not raising any warning, but why does setUnitTypeAAA does? Shouldn't it be at least ignored / accepted?
Thanks.

Answers

  • mstaron
    mstaron Posts: 35

    I agree, this rule incorrectly reports on setUnitTypeAAA, only the parameter in setUnitTypeBBB should be detected. I reported this to the development team.