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

Add clang-format config and enable pre-commit #40

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
BasedOnStyle: Google
AccessModifierOffset: -4
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: Inline
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 120
IncludeBlocks: Preserve
IndentWidth: 4
Language: Cpp
PackConstructorInitializers: Never
PenaltyBreakAssignment: 80
SortIncludes: true
SpacesBeforeTrailingComments: 1
Standard: c++17
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.2
hooks:
- id: clang-format
files: '.*\.(hpp|cpp|h)'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
3 changes: 1 addition & 2 deletions examples/minimal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <QQuickWindow>
#endif

int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/core/geojson_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "types.hpp"

#include <mapbox/geojson.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/util/feature.hpp>
#include <mbgl/util/geometry.hpp>

#include <QVariant>

Expand Down
3 changes: 2 additions & 1 deletion src/core/map_renderer_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <mbgl/renderer/renderer_observer.hpp>
#include <mbgl/util/util.hpp>

#include <QtGlobal>
#include <QObject>

#include <QtGlobal>

#include <memory>
#include <mutex>

Expand Down
3 changes: 2 additions & 1 deletion src/core/renderer_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <mbgl/gfx/backend_scope.hpp>
#include <mbgl/gl/renderable_resource.hpp>

#include <QtGlobal>
#include <QOpenGLContext>

#include <QtGlobal>

namespace QMapLibre {

class RenderableResource final : public mbgl::gl::RenderableResource {
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <mbgl/storage/network_status.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/util/traits.hpp>
#include <mbgl/util/projection.hpp>
#include <mbgl/util/traits.hpp>

// mbgl::NetworkStatus::Status
static_assert(mbgl::underlying_type(QMapLibre::Online) == mbgl::underlying_type(mbgl::NetworkStatus::Status::Online),
Expand Down
8 changes: 4 additions & 4 deletions src/location/plugins/qml_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef QMAPLIBREQMLTYPES_H
#define QMAPLIBREQMLTYPES_H

#include <QtCore/QObject>
#include <QtQml/qqml.h>
#include <QtLocation/private/qdeclarativegeomap_p.h>

#include "../qgeomap.hpp"

#include <QtLocation/private/qdeclarativegeomap_p.h>
#include <QtQml/qqml.h>
#include <QtCore/QObject>

class MapLibreStyleAttached : public QObject {
Q_OBJECT
QML_ANONYMOUS
Expand Down
2 changes: 1 addition & 1 deletion src/location/qgeomap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
#include <QtLocation/private/qdeclarativerectanglemapitem_p.h>
#include <QtLocation/private/qgeoprojection_p.h>
#include <QtQuick/private/qsgcontext_p.h> // for debugging the context name
#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGImageNode>
#include <QtQuick/private/qsgcontext_p.h> // for debugging the context name

#include <QMapLibre/Types>

Expand Down
3 changes: 2 additions & 1 deletion src/location/qgeomap_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

#pragma once

#include <QtLocation/private/qgeomap_p_p.h>

#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QRectF>
#include <QtCore/QSharedPointer>
#include <QtCore/QTimer>
#include <QtCore/QVariant>
#include <QtLocation/private/qgeomap_p_p.h>

namespace QMapLibre {
class Map;
Expand Down
2 changes: 1 addition & 1 deletion src/location/qt_mapping_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "qt_mapping_engine.hpp"
#include "qgeomap.hpp"

#include <QtCore/qdir.h>
#include <QtCore/qstandardpaths.h>
#include <QDir>
#include <QtLocation/private/qabstractgeotilecache_p.h>
#include <QtLocation/private/qgeocameracapabilities_p.h>
#include <QtLocation/private/qgeomaptype_p.h>
Expand Down
2 changes: 1 addition & 1 deletion src/location/qt_mapping_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <QMapLibre/Settings>

#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/private/qgeomappingmanagerengine_p.h>
#include <QtLocation/QGeoServiceProvider>

namespace QMapLibre {

Expand Down
3 changes: 2 additions & 1 deletion src/location/stylechange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

#include "stylechange_p.h"

#include <QtLocation/private/qdeclarativecirclemapitem_p_p.h>

#include <QtCore/QDebug>
#include <QtCore/QMetaProperty>
#include <QtCore/QRegularExpression>
#include <QtCore/QStringList>
#include <QtPositioning/QGeoPath>
#include <QtPositioning/QGeoPolygon>
#include <QtQml/QJSValue>
#include <QtLocation/private/qdeclarativecirclemapitem_p_p.h>

#include <QMapLibre/Map>

Expand Down
11 changes: 6 additions & 5 deletions src/location/stylechange_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@

#pragma once

#include <QtLocation/private/qdeclarativecirclemapitem_p.h>
#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
#include <QtLocation/private/qdeclarativerectanglemapitem_p.h>

#include <QtCore/QList>
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
#include <QtCore/QVariant>
#include <QtCore/QVariantMap>
#include <QtGui/QImage>
#include <QtLocation/private/qdeclarativecirclemapitem_p.h>
#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
#include <QtLocation/private/qdeclarativerectanglemapitem_p.h>

#include <QMapLibre/Types>

Expand Down