-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Format cpp and hpp files in Fw/Types #2677
Conversation
}; | ||
} | ||
|
||
EightyCharString(const char* src); //!< char* source constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
} | ||
|
||
EightyCharString(const char* src); //!< char* source constructor | ||
EightyCharString(const StringBase& src); //!< other string constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
|
||
const char* toChar() const; //!< gets char buffer | ||
NATIVE_UINT_TYPE getCapacity() const; //!< return buffer size | ||
InternalInterfaceString(const char* src); //!< char* source constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
const char* toChar() const; //!< gets char buffer | ||
NATIVE_UINT_TYPE getCapacity() const; //!< return buffer size | ||
InternalInterfaceString(const char* src); //!< char* source constructor | ||
InternalInterfaceString(const StringBase& src); //!< other string constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
|
||
private: | ||
MemAllocator(MemAllocator&); //!< disable | ||
MemAllocator(MemAllocator*); //!< disable |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
PolyType(); //!< default constructor | ||
PolyType(const PolyType &original); //!< copy constructor | ||
virtual ~PolyType(); //!< destructor | ||
PolyType(F32 val); //!< F32 constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
bool isF32(); //!< F32 checker | ||
PolyType& operator=(F32 val); //!< F32 operator= | ||
|
||
PolyType(bool val); //!< bool constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
bool isBool(); //!< bool checker | ||
PolyType& operator=(bool val); //!< bool operator= | ||
|
||
PolyType(void* val); //!< void* constructor. |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
}; | ||
} | ||
|
||
String(const char* src); //!< char* source constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
} | ||
|
||
String(const char* src); //!< char* source constructor | ||
String(const StringBase& src); //!< other string constructor |
Check warning
Code scanning / CppCheck
Single-parameter constructors should be marked explicit. Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
} else { | ||
dest = valString; | ||
} | ||
#if FW_SERIALIZABLE_TO_STRING || BUILD_UT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
case TYPE_I8: | ||
(void)snprintf(valString, sizeof(valString), "%" PRId8 " ", this->m_val.i8Val); | ||
break; | ||
#if FW_HAS_16_BIT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
(void)snprintf(valString, sizeof(valString), "%" PRId16 " ", this->m_val.i16Val); | ||
break; | ||
#endif | ||
#if FW_HAS_32_BIT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
(void)snprintf(valString, sizeof(valString), "%" PRId32 " ", this->m_val.i32Val); | ||
break; | ||
#endif | ||
#if FW_HAS_64_BIT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
#endif | ||
#if FW_HAS_F64 |
Check notice
Code scanning / CodeQL
Conditional compilation Note
|
||
#ifdef BUILD_UT |
Check notice
Code scanning / CodeQL
Conditional compilation Note
This is awesome! I wish we could find an alternative to our idiosyncratic use of PRIVATE/PUBLIC, but I think solving that is a longer term issue and shouldn't hold up code formatting. This script is a great workaround. Only feedback is I'd highly recommend setting up CI to check formatting of |
Adding CI to check formatting as we start formatting is the plan, tracked by #1984 Also, note that we have
or with stdin
|
Great! |
Merge it! Merge it! |
Reformatting improves the readability of the code. If we do it module by module, the impact should be minimal.
Fw/Types
seems like a logical place to start.If someone is developing
Fw/Types
with the old formatting, that person just needs to reformat the code being developed before diffing or making a PR against the new formatting. The catch is that because of the idiosyncratic use of the preprocessor symbolsPRIVATE
andPROTECTED
in F Prime, you can't just run clang-format. Here is the script that I use to work around this issue:I call this tool
fprime-format-cpp
. When run anywhere in the F Prime repo, it picks up the formatting configuration stored in[fprime-root]/.clang-format
, so the formatting should be consistent for all users. It's designed so that you can run it inside a text editor (e.g., vi or VS Code) or in batch mode on the command line.Here is how you can reformat all the files in a build module:
% fprime-format-cpp `find . -name '*.hpp' -or -name '*.cpp'`
I recommend that we put
fprime-format-cpp
, or something like it, into the repo so users can use it to format their code.