Skip to content

Commit 3059574

Browse files
committed
Apply formatting.
1 parent 50604ac commit 3059574

File tree

5 files changed

+152
-90
lines changed

5 files changed

+152
-90
lines changed

.clang-format

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# We'll use defaults from the LLVM style, but with 4 columns indentation.
3+
BasedOnStyle: LLVM
4+
IndentWidth: 2
5+
---
6+
Language: Cpp
7+
DeriveLineEnding: false
8+
UseCRLF: true
9+
DerivePointerAlignment: false
10+
PointerAlignment: Left
11+
AlignConsecutiveAssignments: true
12+
AllowShortFunctionsOnASingleLine: Inline
13+
AllowShortIfStatementsOnASingleLine: Never
14+
AllowShortLambdasOnASingleLine: Empty
15+
AlwaysBreakTemplateDeclarations: Yes
16+
AccessModifierOffset: -2
17+
AlignTrailingComments: true
18+
SpacesBeforeTrailingComments: 2
19+
NamespaceIndentation: Inner
20+
MaxEmptyLinesToKeep: 1
21+
BreakBeforeBraces: Custom
22+
BraceWrapping:
23+
AfterCaseLabel: false
24+
AfterClass: true
25+
AfterControlStatement: false
26+
AfterEnum: true
27+
AfterFunction: true
28+
AfterNamespace: true
29+
AfterStruct: true
30+
AfterUnion: true
31+
AfterExternBlock: true
32+
BeforeCatch: false
33+
BeforeElse: false
34+
BeforeLambdaBody: false
35+
BeforeWhile: false
36+
IndentBraces: false
37+
SplitEmptyFunction: false
38+
SplitEmptyRecord: false
39+
SplitEmptyNamespace: true
40+
ColumnLimit: 88
41+
ForEachMacros: ['Q_FOREACH', 'foreach']

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.cpp text eol=crlf
7+
*.h text eol=crlf

.github/workflows/linting.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Lint Github++
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Check format
14+
uses: ModOrganizer2/check-formatting-action@master
15+
with:
16+
check-path: "."

include/githubpp/github.h

+31-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
#pragma once
22

3-
#include <QNetworkAccessManager>
4-
#include <QNetworkCookieJar>
3+
#include <QJsonArray>
54
#include <QJsonDocument>
65
#include <QJsonObject>
7-
#include <QJsonArray>
8-
#include <QTimer>
6+
#include <QNetworkAccessManager>
7+
#include <QNetworkCookieJar>
98
#include <QNetworkReply>
9+
#include <QTimer>
1010
#include <functional>
1111

1212
class GitHubException : public std::exception
1313
{
1414
public:
15-
GitHubException(const QJsonObject &errorObj)
16-
: std::exception()
15+
GitHubException(const QJsonObject& errorObj) : std::exception()
1716
{
1817
initMessage(errorObj);
1918
}
2019

2120
virtual ~GitHubException() throw() override {}
2221

23-
virtual const char *what() const throw()
24-
{
25-
return m_Message.constData();
26-
}
22+
virtual const char* what() const throw() { return m_Message.constData(); }
2723

2824
private:
29-
void initMessage(const QJsonObject &obj)
25+
void initMessage(const QJsonObject& obj)
3026
{
3127
if (obj.contains("http_status")) {
3228
m_Message = QString("HTTP Status %1: %2")
@@ -55,48 +51,51 @@ class GitHub : public QObject
5551
Q_OBJECT
5652

5753
public:
58-
enum class Method { GET, POST };
54+
enum class Method
55+
{
56+
GET,
57+
POST
58+
};
5959

60-
struct Repository {
61-
Repository(const QString &owner, const QString &project)
62-
: owner(owner)
63-
, project(project)
64-
{
65-
}
60+
struct Repository
61+
{
62+
Repository(const QString& owner, const QString& project)
63+
: owner(owner), project(project)
64+
{}
6665
QString owner;
6766
QString project;
6867
};
6968

7069
public:
71-
GitHub(const char *clientId = nullptr);
70+
GitHub(const char* clientId = nullptr);
7271
~GitHub();
7372

74-
QJsonArray releases(const Repository &repo);
75-
void releases(const Repository &repo,
76-
const std::function<void (const QJsonArray &)> &callback);
73+
QJsonArray releases(const Repository& repo);
74+
void releases(const Repository& repo,
75+
const std::function<void(const QJsonArray&)>& callback);
7776

7877
private:
79-
QJsonDocument request(Method method, const QString &path,
80-
const QByteArray &data, bool relative);
81-
void request(Method method, const QString &path, const QByteArray &data,
82-
const std::function<void (const QJsonDocument &)> &callback,
78+
QJsonDocument request(Method method, const QString& path, const QByteArray& data,
79+
bool relative);
80+
void request(Method method, const QString& path, const QByteArray& data,
81+
const std::function<void(const QJsonDocument&)>& callback,
8382
bool relative);
8483

85-
QJsonDocument handleReply(QNetworkReply *reply);
86-
QNetworkReply *genReply(Method method, const QString &path,
87-
const QByteArray &data, bool relative);
84+
QJsonDocument handleReply(QNetworkReply* reply);
85+
QNetworkReply* genReply(Method method, const QString& path, const QByteArray& data,
86+
bool relative);
8887

8988
private:
9089
struct Request
9190
{
9291
Method method = Method::GET;
9392
QByteArray data;
94-
std::function<void (const QJsonDocument &)> callback;
95-
QTimer* timer = nullptr;
93+
std::function<void(const QJsonDocument&)> callback;
94+
QTimer* timer = nullptr;
9695
QNetworkReply* reply = nullptr;
9796
};
9897

99-
QNetworkAccessManager *m_AccessManager;
98+
QNetworkAccessManager* m_AccessManager;
10099

101100
// remember the replies that are in flight and delete them in the destructor
102101
std::vector<QNetworkReply*> m_replies;

0 commit comments

Comments
 (0)