-
-
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
.clang-format: Set column limit to 80 #2486
Conversation
Right now, running clang-format or git clang-format will unwrap lines and make them longer than 80 chars, even if the developer inserted linebreaks manually.
We had long discussions if we should define a limit or not. As a workaround line breaks can be preserved by placing arguments on separate lines. If we decide to set a limit the comment becomes obsolete and should be removed. |
I am fine with the current solution, allow lines until scrolling with GitHub. Manually break < 80 in a way clang does not unbreak it. Unfortunately clang format leaks two independent parameters for this. |
Right now, the situation is really bad, because I have code that fits our coding style and running clang-format breaks it. This is probably the worst case scenario for an auto-formatter. I don't really know what's the best way forward, but I see 4 options here:
|
Please point me to the code. There should be a way not to break our coding style and clang-format is happy. |
Exhibit ADiff after running clang-format: -QString parseCrate(const QSqlDatabase& database, QString databasePath,
- QString crateFilePath, const QMap<QString, int>& trackIdMap) {
+QString parseCrate(const QSqlDatabase& database, QString databasePath, QString crateFilePath, const QMap<QString, int>& trackIdMap) { Exhibit B- "INSERT INTO " + kSeratoLibraryTable + " ("
- + LIBRARYTABLE_TITLE + ", "
- + LIBRARYTABLE_ARTIST + ", "
- + LIBRARYTABLE_ALBUM + ", "
- + LIBRARYTABLE_GENRE + ", "
- + LIBRARYTABLE_COMMENT + ", "
- + LIBRARYTABLE_GROUPING + ", "
- + LIBRARYTABLE_YEAR + ", "
- + LIBRARYTABLE_DURATION + ", "
- + LIBRARYTABLE_BITRATE + ", "
- + LIBRARYTABLE_SAMPLERATE + ", "
- + LIBRARYTABLE_BPM + ", "
- + LIBRARYTABLE_KEY + ", "
- + LIBRARYTABLE_LOCATION + ", "
- + LIBRARYTABLE_BPM_LOCK + ", "
- + LIBRARYTABLE_DATETIMEADDED + ", "
+ "INSERT INTO " + kSeratoLibraryTable + " (" + LIBRARYTABLE_TITLE + ", " + LIBRARYTABLE_ARTIST + ", " + LIBRARYTABLE_ALBUM + ", " + LIBRARYTABLE_GENRE + ", " + LIBRARYTABLE_COMMENT + ", " + LIBRARYTABLE_GROUPING + ", " + LIBRARYTABLE_YEAR + ", " + LIBRARYTABLE_DURATION + ", " + LIBRARYTABLE_BITRATE + ", " + LIBRARYTABLE_SAMPLERATE + ", " + LIBRARYTABLE_BPM + ", " + LIBRARYTABLE_KEY + ", " + LIBRARYTABLE_LOCATION + ", " + LIBRARYTABLE_BPM_LOCK + ", " + LIBRARYTABLE_DATETIMEADDED +
+ ", " Exhibit CSee #2480 (comment) - m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_ARTIST]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ARTIST);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_TITLE]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TITLE);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_ALBUM]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ALBUM);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_ALBUMARTIST]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ALBUMARTIST);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_YEAR]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_YEAR);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_GENRE]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GENRE);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_COMPOSER]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMPOSER);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_GROUPING]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GROUPING);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_TRACKNUMBER]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TRACKNUMBER);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_FILETYPE]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_FILETYPE);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_NATIVELOCATION]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_NATIVELOCATION);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_COMMENT]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMMENT);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_DURATION]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DURATION);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_BITRATE]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BITRATE);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_BPM]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_REPLAYGAIN]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_REPLAYGAIN);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_DATETIMEADDED]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DATETIMEADDED);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_TIMESPLAYED]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_RATING]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_RATING);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_KEY]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_PREVIEW]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_COVERART]
- = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART);
- m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_POSITION]
- = fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_ARTIST] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ARTIST);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_TITLE] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TITLE);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_ALBUM] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ALBUM);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_ALBUMARTIST] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_ALBUMARTIST);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_YEAR] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_YEAR);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_GENRE] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GENRE);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_COMPOSER] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMPOSER);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_GROUPING] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_GROUPING);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_TRACKNUMBER] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TRACKNUMBER);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_FILETYPE] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_FILETYPE);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_NATIVELOCATION] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_NATIVELOCATION);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_COMMENT] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMMENT);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_DURATION] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DURATION);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_BITRATE] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BITRATE);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_BPM] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_REPLAYGAIN] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_REPLAYGAIN);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_DATETIMEADDED] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_DATETIMEADDED);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_TIMESPLAYED] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_RATING] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_RATING);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_KEY] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_KEY);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_PREVIEW] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_COVERART] = fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART);
+ m_columnIndexBySortColumnId[TrackModel::SortColumnId::SORTCOLUMN_POSITION] = fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION); |
The trick is
|
I think we need to update the style guide. |
Thanks. From https://www.mixxx.org/wiki/doku.php/coding_guidelines#line_widths :
I guess hanging indents are not possible with clang-format? |
No. I deleted the redundant and incorrect sentence. |
So we can close this? |
Yup. If more issues arise we need to adapt the wiki and make sure it doesn't conflict with clang-format. |
Right now, running clang-format or git clang-format will unwrap lines
and make them longer than 80 chars, even if the developer inserted
linebreaks manually.