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

Pass methods arguments by const refs #161

Merged
merged 5 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/Core/Formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ namespace Core
class Formatter
{
public:
Formatter(QString clangFormatBinary, const QString &clangFormatStyle, MessageLogger *log);
Formatter(const QString &clangFormatBinary, const QString &clangFormatStyle, MessageLogger *log);
void format(QCodeEditor *editor, const QString &filePath, const QString &lang, bool selectionOnly);
static bool check(QString checkBinary, const QString &checkStyle);
void updateBinary(QString newBinary);
static bool check(const QString &checkBinary, const QString &checkStyle);
void updateBinary(const QString &newBinary);
void updateStyle(const QString &newStyle);

private:
Expand Down
14 changes: 7 additions & 7 deletions src/Core/Formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@

namespace Core
{
Formatter::Formatter(QString clangFormatBinary, const QString &clangFormatStyle, MessageLogger *log)
Formatter::Formatter(const QString &clangFormatBinary, const QString &clangFormatStyle, MessageLogger *log)
{
this->log = log;
updateBinary(clangFormatBinary);
updateStyle(clangFormatStyle);
Formatter::updateBinary(clangFormatBinary);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not fully qualify the name. It may confuse users to think that updateBinary is a static function.

Formatter::updateStyle(clangFormatStyle);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing. Do not fully qualify the method name.

}

bool Formatter::check(QString checkBinary, const QString &checkStyle)
bool Formatter::check(const QString &checkBinary, const QString &checkStyle)
{
QTemporaryDir tmpDir;
if (!tmpDir.isValid())
Expand All @@ -49,14 +49,14 @@ bool Formatter::check(QString checkBinary, const QString &checkStyle)
return program.exitCode() == 0;
}

void Formatter::updateBinary(QString newBinary)
void Formatter::updateBinary(const QString& newBinary)
{
binary = newBinary;
this->binary = newBinary;
}

void Formatter::updateStyle(const QString &newStyle)
{
style = newStyle;
this->style = newStyle;
}

void Formatter::format(QCodeEditor *editor, const QString &filePath, const QString &lang, bool selectionOnly)
Expand Down