Add lint github action (#2473)

This commit is contained in:
pajlada 2021-02-21 14:45:42 +01:00 committed by GitHub
parent 714048a29e
commit e015013773
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 207 additions and 128 deletions

21
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,21 @@
---
name: Lint
on:
push:
branches:
- master
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- name: Lint Markdown files
uses: actionsx/prettier@v2
with:
# prettier CLI arguments.
args: --check '**/*.md'

5
.prettierignore Normal file
View file

@ -0,0 +1,5 @@
# Ignore submodule files
lib/*/
conan-pkgs/*/
.github/

6
.prettierrc.toml Normal file
View file

@ -0,0 +1,6 @@
trailingComma = "es5"
[[overrides]]
files = ["*.md"]
[overrides.options]
proseWrap = "preserve"

View file

@ -9,9 +9,7 @@ high that this also works on older FreeBSD releases, architectures and
FreeBSD 13.0-CURRENT. FreeBSD 13.0-CURRENT.
1. Install build dependencies from package sources (or build from the 1. Install build dependencies from package sources (or build from the
ports tree): `# pkg install qt5-core qt5-multimedia qt5-svg ports tree): `# pkg install qt5-core qt5-multimedia qt5-svg qt5-qmake qt5-buildtools gstreamer-plugins-good boost-libs rapidjson`
qt5-qmake qt5-buildtools gstreamer-plugins-good boost-libs
rapidjson`
1. go into project directory 1. go into project directory
1. create build folder `$ mkdir build && cd build` 1. create build folder `$ mkdir build && cd build`
1. `$ qmake .. && make` 1. `$ qmake .. && make`

View file

@ -3,29 +3,40 @@
Note on Qt version compatibility: If you are installing Qt from a package manager, please ensure the version you are installing is at least **Qt 5.12 or newer**. Note on Qt version compatibility: If you are installing Qt from a package manager, please ensure the version you are installing is at least **Qt 5.12 or newer**.
## Ubuntu 18.04 ## Ubuntu 18.04
*most likely works the same for other Debian-like distros*
_most likely works the same for other Debian-like distros_
1. Install dependencies (and the C++ IDE Qt Creator) `sudo apt install qtcreator qtmultimedia5-dev libqt5svg5-dev libboost-dev libssl-dev libboost-system-dev libboost-filesystem-dev` 1. Install dependencies (and the C++ IDE Qt Creator) `sudo apt install qtcreator qtmultimedia5-dev libqt5svg5-dev libboost-dev libssl-dev libboost-system-dev libboost-filesystem-dev`
1. Open `chatterino.pro` with QT Creator and build 1. Open `chatterino.pro` with QT Creator and build
## Arch Linux ## Arch Linux
install [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) from the aur or build manually as follows: install [chatterino2-git](https://aur.archlinux.org/packages/chatterino2-git/) from the aur or build manually as follows:
1. `sudo pacman -S qt5-base qt5-multimedia qt5-svg gst-plugins-ugly gst-plugins-good boost rapidjson pkgconf openssl` 1. `sudo pacman -S qt5-base qt5-multimedia qt5-svg gst-plugins-ugly gst-plugins-good boost rapidjson pkgconf openssl`
1. go into project directory 1. go into project directory
1. create build folder `mkdir build && cd build` 1. create build folder `mkdir build && cd build`
1. `qmake .. && make` 1. `qmake .. && make`
## Fedora 28 and above ## Fedora 28 and above
*most likely works the same for other Red Hat-like distros. Substitue `dnf` with `yum`.*
_most likely works the same for other Red Hat-like distros. Substitue `dnf` with `yum`._
### Development dependencies ### Development dependencies
1. `sudo dnf install qt5-qtbase-devel qt5-qtmultimedia-devel qt5-qtsvg-devel libsecret-devel openssl-devel boost-devel` 1. `sudo dnf install qt5-qtbase-devel qt5-qtmultimedia-devel qt5-qtsvg-devel libsecret-devel openssl-devel boost-devel`
1. go into project directory 1. go into project directory
1. create build folder `mkdir build && cd build` 1. create build folder `mkdir build && cd build`
1. `qmake-qt5 .. && make -j$(nproc)` 1. `qmake-qt5 .. && make -j$(nproc)`
### Optional dependencies ### Optional dependencies
*`gstreamer-plugins-good` package is retired in Fedora 31, see: [rhbz#1735324](https://bugzilla.redhat.com/show_bug.cgi?id=1735324)*
1. `sudo dnf install gstreamer-plugins-good` *(optional: for audio output)* _`gstreamer-plugins-good` package is retired in Fedora 31, see: [rhbz#1735324](https://bugzilla.redhat.com/show_bug.cgi?id=1735324)_
1. `sudo dnf install gstreamer-plugins-good` _(optional: for audio output)_
## NixOS 18.09+ ## NixOS 18.09+
1. enter the development environment with all of the dependencies: `nix-shell -p openssl boost qt5.full pkg-config` 1. enter the development environment with all of the dependencies: `nix-shell -p openssl boost qt5.full pkg-config`
1. go into project directory 1. go into project directory
1. create build folder `mkdir build && cd build` 1. create build folder `mkdir build && cd build`

View file

@ -1,15 +1,18 @@
# Building on macOS # Building on macOS
#### Note - If you want to develop Chatterino 2 you will also need to install Qt Creator (make sure to install **Qt 5.12 or newer**) #### Note - If you want to develop Chatterino 2 you will also need to install Qt Creator (make sure to install **Qt 5.12 or newer**)
#### Note - Chatterino 2 is only tested on macOS 10.14 and above - anything below that is considered unsupported. It may or may not work on earlier versions #### Note - Chatterino 2 is only tested on macOS 10.14 and above - anything below that is considered unsupported. It may or may not work on earlier versions
1. Install Xcode and Xcode Command Line Utilites 1. Install Xcode and Xcode Command Line Utilites
2. Start Xcode, settings -> Locations, activate your Command Line Tools 2. Start Xcode, settings -> Locations, activate your Command Line Tools
3. Install brew https://brew.sh/ 3. Install brew https://brew.sh/
4. `brew install boost openssl rapidjson` 4. `brew install boost openssl rapidjson`
5. `brew install qt` 5. `brew install qt`
6. Step 5 should output some directions to add qt to your path, you will need to do this for qmake 6. Step 5 should output some directions to add qt to your path, you will need to do this for qmake
5. Go into project directory 7. Go into project directory
6. Create build folder `mkdir build && cd build` 8. Create build folder `mkdir build && cd build`
7. `qmake .. && make` 9. `qmake .. && make`
If the Project does not build at this point, you might need to add additional Paths/Libs, because brew does not install openssl and boost in the common path. You can get their path using If the Project does not build at this point, you might need to add additional Paths/Libs, because brew does not install openssl and boost in the common path. You can get their path using
@ -17,6 +20,7 @@ If the Project does not build at this point, you might need to add additional Pa
`brew info boost` `brew info boost`
If brew doesn't link openssl properly then you should be able to link it yourself using those two commands: If brew doesn't link openssl properly then you should be able to link it yourself using those two commands:
- `ln -s /usr/local/opt/openssl/lib/* /usr/local/lib` - `ln -s /usr/local/opt/openssl/lib/* /usr/local/lib`
- `ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl` - `ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl`

View file

@ -10,30 +10,35 @@ Download and install [Visual Studio 2019 Community](https://visualstudio.microso
Notes: Notes:
- This installation will take about 17 GB of disk space - This installation will take about 17 GB of disk space
- You do not need to sign in with a Microsoft account after setup completes. You may simply exit the login dialog. - You do not need to sign in with a Microsoft account after setup completes. You may simply exit the login dialog.
## Boost ## Boost
1. First, download a boost installer appropriate for your version of Visual Studio. 1. First, download a boost installer appropriate for your version of Visual Studio.
- Visit the downloads list [on Bintray](https://dl.bintray.com/boostorg/release/). - Visit the downloads list [on Bintray](https://dl.bintray.com/boostorg/release/).
- Select the latest version from the list and navigate into the `binaries/` directory. - Select the latest version from the list and navigate into the `binaries/` directory.
- Download the `.exe` file appropriate to your Visual Studio installation version and system bitness (choose `x64` for 64-bit systems). - Download the `.exe` file appropriate to your Visual Studio installation version and system bitness (choose `x64` for 64-bit systems).
Visual Studio versions map as follows: `14.2` in the filename corresponds to MSVC 2019, `14.1` to 2017, `14.0` to 2015. _Anything prior to Visual Studio 2015 is unsupported. Please upgrade should you have an older installation._ Visual Studio versions map as follows: `14.2` in the filename corresponds to MSVC 2019, `14.1` to 2017, `14.0` to 2015. _Anything prior to Visual Studio 2015 is unsupported. Please upgrade should you have an older installation._
**Convenience link for Visual Studio 2019: [Boost 1.75.0-MSVC-14.2](https://dl.bintray.com/boostorg/release/1.75.0/binaries/boost_1_75_0-msvc-14.2-64.exe)** **Convenience link for Visual Studio 2019: [Boost 1.75.0-MSVC-14.2](https://dl.bintray.com/boostorg/release/1.75.0/binaries/boost_1_75_0-msvc-14.2-64.exe)**
2. When prompted where to install Boost, set the location to `C:\local\boost`. 2. When prompted where to install Boost, set the location to `C:\local\boost`.
3. After the installation finishes, rename the `C:\local\boost\lib64-msvc-14.2` (or similar) directory to simply `lib` (`C:\local\boost\lib`). 3. After the installation finishes, rename the `C:\local\boost\lib64-msvc-14.2` (or similar) directory to simply `lib` (`C:\local\boost\lib`).
Note: This installation will take about 1.5 GB of disk space. Note: This installation will take about 1.5 GB of disk space.
## OpenSSL ## OpenSSL
### For our websocket library, we need OpenSSL 1.1 ### For our websocket library, we need OpenSSL 1.1
1. Download OpenSSL for windows, version `1.1.1i`: **[Download](https://slproweb.com/download/Win64OpenSSL-1_1_1i.exe)** 1. Download OpenSSL for windows, version `1.1.1i`: **[Download](https://slproweb.com/download/Win64OpenSSL-1_1_1i.exe)**
2. When prompted, install OpenSSL to `C:\local\openssl` 2. When prompted, install OpenSSL to `C:\local\openssl`
3. When prompted, copy the OpenSSL DLLs to "The OpenSSL binaries (/bin) directory". 3. When prompted, copy the OpenSSL DLLs to "The OpenSSL binaries (/bin) directory".
### For Qt SSL, we need OpenSSL 1.0 ### For Qt SSL, we need OpenSSL 1.0
1. Download OpenSSL for windows, version `1.0.2u`: **[Download](https://slproweb.com/download/Win64OpenSSL-1_0_2u.exe)** 1. Download OpenSSL for windows, version `1.0.2u`: **[Download](https://slproweb.com/download/Win64OpenSSL-1_0_2u.exe)**
2. When prompted, install it to any arbitrary empty directory. 2. When prompted, install it to any arbitrary empty directory.
3. When prompted, copy the OpenSSL DLLs to "The OpenSSL binaries (/bin) directory". 3. When prompted, copy the OpenSSL DLLs to "The OpenSSL binaries (/bin) directory".
@ -46,12 +51,14 @@ Note: This installation will take about 1.5 GB of disk space.
Note: This installation will take about 200 MB of disk space. Note: This installation will take about 200 MB of disk space.
## Qt ## Qt
1. Visit the [Qt Open Source Page](https://www.qt.io/download-open-source). 1. Visit the [Qt Open Source Page](https://www.qt.io/download-open-source).
2. Scroll down to the bottom 2. Scroll down to the bottom
3. Then select "Download the Qt Online Installer" 3. Then select "Download the Qt Online Installer"
Notes: Notes:
- Installing the latest **stable** Qt version is advised for new installations, but if you want to use your existing installation please ensure you are running **Qt 5.12 or later**.
- Installing the latest **stable** Qt version is advised for new installations, but if you want to use your existing installation please ensure you are running **Qt 5.12 or later**.
### When prompted which components to install: ### When prompted which components to install:
@ -66,6 +73,7 @@ Notes:
Note: This installation will take about 2 GB of disk space. Note: This installation will take about 2 GB of disk space.
## Compile with Breakpad support (Optional) ## Compile with Breakpad support (Optional)
Compiling with Breakpad support enables crash reports that can be of use for developing/beta versions of Chatterino. If you have no interest in reporting crashes anyways, this optional dependency will probably be of no use to you. Compiling with Breakpad support enables crash reports that can be of use for developing/beta versions of Chatterino. If you have no interest in reporting crashes anyways, this optional dependency will probably be of no use to you.
1. Open up `lib/qBreakpad/handler/handler.pro`in Qt Creator 1. Open up `lib/qBreakpad/handler/handler.pro`in Qt Creator
@ -73,6 +81,7 @@ Compiling with Breakpad support enables crash reports that can be of use for dev
3. Copy the newly built `qBreakpad.lib` to the following directory: `lib/qBreakpad/build/handler` (You will have to manually create this directory) 3. Copy the newly built `qBreakpad.lib` to the following directory: `lib/qBreakpad/build/handler` (You will have to manually create this directory)
## Run the build in Qt Creator ## Run the build in Qt Creator
1. Open the `chatterino.pro` file by double-clicking or by opening it via Qt Creator. 1. Open the `chatterino.pro` file by double-clicking or by opening it via Qt Creator.
2. You will be presented with a screen that is titled "Configure Project". In this screen, you should have at least one option present ready to be configured, like this: 2. You will be presented with a screen that is titled "Configure Project". In this screen, you should have at least one option present ready to be configured, like this:
![Qt Create Configure Project screenshot](https://i.imgur.com/dbz45mB.png) ![Qt Create Configure Project screenshot](https://i.imgur.com/dbz45mB.png)
@ -80,13 +89,13 @@ Compiling with Breakpad support enables crash reports that can be of use for dev
### How to run and produce builds ### How to run and produce builds
- In the main screen, click the green "play symbol" on the bottom left to run the project directly. - In the main screen, click the green "play symbol" on the bottom left to run the project directly.
- Click the hammer on the bottom left to generate a build (does not run the build though). - Click the hammer on the bottom left to generate a build (does not run the build though).
Build results will be placed in a folder at the same level as the "chatterino2" project folder (e.g. if your sources are at `C:\Users\example\src\chatterino2`, then the build will be placed in an automatically generated folder under `C:\Users\example\src`, e.g. `C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release`.) Build results will be placed in a folder at the same level as the "chatterino2" project folder (e.g. if your sources are at `C:\Users\example\src\chatterino2`, then the build will be placed in an automatically generated folder under `C:\Users\example\src`, e.g. `C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release`.)
- Note that if you are building chatterino purely for usage, not for development, it is recommended that you click the "PC" icon above the play icon and select "Release" instead of "Debug". - Note that if you are building chatterino purely for usage, not for development, it is recommended that you click the "PC" icon above the play icon and select "Release" instead of "Debug".
- Output and error messages produced by the compiler can be seen under the "4 Compile Output" tab in Qt Creator. - Output and error messages produced by the compiler can be seen under the "4 Compile Output" tab in Qt Creator.
## Producing standalone builds ## Producing standalone builds
@ -96,21 +105,21 @@ To produce a standalone package, you need to generate all required files using t
To produce all supplement files for a standalone build, follow these steps (adjust paths as required): To produce all supplement files for a standalone build, follow these steps (adjust paths as required):
1. Navigate to your build output directory with windows explorer, e.g. `C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release` 1. Navigate to your build output directory with windows explorer, e.g. `C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release`
2. Enter the `release` directory 2. Enter the `release` directory
3. Delete all files except the `chatterino.exe` file. You should be left with a directory only containing `chatterino.exe`. 3. Delete all files except the `chatterino.exe` file. You should be left with a directory only containing `chatterino.exe`.
4. Open a `cmd` window and execute: 4. Open a `cmd` window and execute:
cd C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\release cd C:\Users\example\src\build-chatterino-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\release
C:\Qt\5.15.2\msvc2019_64\bin\windeployqt.exe chatterino.exe C:\Qt\5.15.2\msvc2019_64\bin\windeployqt.exe chatterino.exe
5. Go to `C:\local\bin\` and copy these dll's into your `release folder`. 5. Go to `C:\local\bin\` and copy these dll's into your `release folder`.
libssl-1_1-x64.dll libssl-1_1-x64.dll
libcrypto-1_1-x64.dll libcrypto-1_1-x64.dll
ssleay32.dll ssleay32.dll
libeay32.dll libeay32.dll
6. The `releases` directory will now be populated with all the required files to make the chatterino build standalone. 6. The `releases` directory will now be populated with all the required files to make the chatterino build standalone.
You can now create a zip archive of all the contents in `releases` and distribute the program as is, without requiring any development tools to be present on the target system. (However, the vcredist package must be present, as usual - see the [README](README.md)). You can now create a zip archive of all the contents in `releases` and distribute the program as is, without requiring any development tools to be present on the target system. (However, the vcredist package must be present, as usual - see the [README](README.md)).

View file

@ -4,8 +4,7 @@ This is a set of guidelines for contributing to Chatterino. The goal is to teach
# Tooling # Tooling
Formatting ## Formatting
------
Code is automatically formatted using `clang-format`. It takes the burden off of the programmer and ensures that all contributors use the same style (even if mess something up accidentally). We recommend that you set up automatic formatting on file save in your editor. Code is automatically formatted using `clang-format`. It takes the burden off of the programmer and ensures that all contributors use the same style (even if mess something up accidentally). We recommend that you set up automatic formatting on file save in your editor.
@ -20,7 +19,7 @@ Try to structure your code so that comments are not required.
#### Good example #### Good example
``` cpp ```cpp
/// Result is 0 if a == b, negative if a < b and positive if b > a. /// Result is 0 if a == b, negative if a < b and positive if b > a.
/// ^^^ You can't know this from the function signature! /// ^^^ You can't know this from the function signature!
// Even better: Return a "strong ordering" type. // Even better: Return a "strong ordering" type.
@ -30,7 +29,7 @@ int compare(const QString &a, const QString &b);
#### Bad example #### Bad example
``` cpp ```cpp
/* /*
* Matches a link and returns boost::none if it failed and a * Matches a link and returns boost::none if it failed and a
* QRegularExpressionMatch on success. * QRegularExpressionMatch on success.
@ -43,15 +42,13 @@ int compare(const QString &a, const QString &b);
boost::optional<QRegularExpressionMatch> matchLink(const QString &text); boost::optional<QRegularExpressionMatch> matchLink(const QString &text);
``` ```
# Code # Code
Arithmetic Types ## Arithmetic Types
-----
Arithmetic types (like char, short, int, long, float and double), bool, and pointers are NOT initialized by default in c++. They keep whatever value is already at their position in the memory. This makes debugging harder and is unpredictable, so we initialize them to zero by using `{}` after their name when declaring them. Arithmetic types (like char, short, int, long, float and double), bool, and pointers are NOT initialized by default in c++. They keep whatever value is already at their position in the memory. This makes debugging harder and is unpredictable, so we initialize them to zero by using `{}` after their name when declaring them.
``` cpp ```cpp
class ArithmeticTypes class ArithmeticTypes
{ {
int thisIs0{}; int thisIs0{};
@ -71,12 +68,13 @@ void myFunc() {
} }
``` ```
Passing parameters ## Passing parameters
------
The way a parameter is passed signals how it is going to be used inside of the function. C++ doesn't have multiple return values so there is "out parameters" (reference to a variable that is going to be assigned inside of the function) to simulate multiple return values. The way a parameter is passed signals how it is going to be used inside of the function. C++ doesn't have multiple return values so there is "out parameters" (reference to a variable that is going to be assigned inside of the function) to simulate multiple return values.
**Cheap to copy types** like int/enum/etc. can be passed in per value since copying them is fast. **Cheap to copy types** like int/enum/etc. can be passed in per value since copying them is fast.
``` cpp
```cpp
void setValue(int value) { void setValue(int value) {
// ... // ...
} }
@ -84,20 +82,20 @@ void setValue(int value) {
**References** mean that the variable doesn't need to be copied when it is passed to a function. **References** mean that the variable doesn't need to be copied when it is passed to a function.
|type|meaning| | type | meaning |
|-|-| | ------------------ | ---------------------------------------------------------------------------------------- |
|`const Type& name`|*in* Parameter. It is NOT going to be modified and may be copied inside of the function.| | `const Type& name` | _in_ Parameter. It is NOT going to be modified and may be copied inside of the function. |
|`Type& name`|*out* or *in+out* Parmameter. It will be modified.| | `Type& name` | _out_ or _in+out_ Parmameter. It will be modified. |
**Pointers** signal that objects are managed manually. While the above are only guaranteed to live as long as the function call (= don't store and use later) these may have more complex lifetimes. **Pointers** signal that objects are managed manually. While the above are only guaranteed to live as long as the function call (= don't store and use later) these may have more complex lifetimes.
|type|meaning| | type | meaning |
|-|-| | ------------ | -------------------------------------------------------------------------------------------------------------------------- |
|`Type* name`|The lifetime of the parameter may exceed the length of the function call. It may use the `QObject` parent/children system.| | `Type* name` | The lifetime of the parameter may exceed the length of the function call. It may use the `QObject` parent/children system. |
**R-value references** `&&` work similar to regular references but signal the parameter should be "consumed". **R-value references** `&&` work similar to regular references but signal the parameter should be "consumed".
``` cpp ```cpp
void storeLargeObject(LargeObject &&object) { void storeLargeObject(LargeObject &&object) {
// ... // ...
} }
@ -126,12 +124,11 @@ void main() {
Generally the lowest level of requirement should be used e.g. passing `Channel&` instead of `std::shared_ptr<Channel>&` (aka `ChannelPtr`) if possible. Generally the lowest level of requirement should be used e.g. passing `Channel&` instead of `std::shared_ptr<Channel>&` (aka `ChannelPtr`) if possible.
## Members
Members All functions names are in `camelCase`. _Private_ member variables are in `camelCase_` (note the underscore at the end). We don't use the `get` prefix for getters. We mark functions as `const` [if applicable](https://stackoverflow.com/questions/751681/meaning-of-const-last-in-a-function-declaration-of-a-class).
-----
All functions names are in `camelCase`. *Private* member variables are in `camelCase_` (note the underscore at the end). We don't use the `get` prefix for getters. We mark functions as `const` [if applicable](https://stackoverflow.com/questions/751681/meaning-of-const-last-in-a-function-declaration-of-a-class). ```cpp
``` cpp
class NamedObject class NamedObject
{ {
public: public:
@ -151,15 +148,14 @@ private:
void myFreeStandingFunction(); // <- also lower case void myFreeStandingFunction(); // <- also lower case
``` ```
Casts ## Casts
------
- **Avoid** c-style casts: `(type)variable`. - **Avoid** c-style casts: `(type)variable`.
- Instead use explicit type casts: `type(variable)` - Instead use explicit type casts: `type(variable)`
- Or use one of [static_cast](https://en.cppreference.com/w/cpp/language/static_cast), [const_cast](https://en.cppreference.com/w/cpp/language/const_cast) and [dynamic_cast](https://en.cppreference.com/w/cpp/language/dynamic_cast) - Or use one of [static_cast](https://en.cppreference.com/w/cpp/language/static_cast), [const_cast](https://en.cppreference.com/w/cpp/language/const_cast) and [dynamic_cast](https://en.cppreference.com/w/cpp/language/dynamic_cast)
- Try to avoid [reinterpret_cast](https://en.cppreference.com/w/cpp/language/reinterpret_cast) unless necessary. - Try to avoid [reinterpret_cast](https://en.cppreference.com/w/cpp/language/reinterpret_cast) unless necessary.
``` cpp ```cpp
void example() { void example() {
float f = 123.456; float f = 123.456;
int i = (int)f; // <- don't int i = (int)f; // <- don't
@ -181,12 +177,11 @@ void example() {
} }
``` ```
## This
This
------
Always use `this` to refer to instance members to make it clear where we use either locals or members. Always use `this` to refer to instance members to make it clear where we use either locals or members.
``` cpp ```cpp
class Test class Test
{ {
void testFunc(int a); void testFunc(int a);
@ -206,15 +201,17 @@ Test::testFunc(int a)
} }
``` ```
Managing resources ## Managing resources
------
#### Regular classes #### Regular classes
Keep the element on the stack if possible. If you need a pointer or have complex ownership you should use one of these classes: Keep the element on the stack if possible. If you need a pointer or have complex ownership you should use one of these classes:
- Use `std::unique_ptr` if the resource has a single owner. - Use `std::unique_ptr` if the resource has a single owner.
- Use `std::shared_ptr` if the resource has multiple owners. - Use `std::shared_ptr` if the resource has multiple owners.
#### QObject classes #### QObject classes
- Use the [object tree](https://doc.qt.io/qt-5/objecttrees.html#) to manage lifetime where possible. Objects are destroyed when their parent object is destroyed. - Use the [object tree](https://doc.qt.io/qt-5/objecttrees.html#) to manage lifetime where possible. Objects are destroyed when their parent object is destroyed.
- If you have to explicitly delete an object use `variable->deleteLater()` instead of `delete variable`. This ensures that it will be deleted on the correct thread. - If you have to explicitly delete an object use `variable->deleteLater()` instead of `delete variable`. This ensures that it will be deleted on the correct thread.
- If an object doesn't have a parent consider using `std::unique_ptr<Type, DeleteLater>` with `DeleteLater` from "src/common/Common.hpp". This will call `deleteLater()` on the pointer once it goes out of scope or the object is destroyed. - If an object doesn't have a parent consider using `std::unique_ptr<Type, DeleteLater>` with `DeleteLater` from "src/common/Common.hpp". This will call `deleteLater()` on the pointer once it goes out of scope or the object is destroyed.

View file

@ -7,22 +7,27 @@ The Chatterino 2 wiki can be found [here](https://wiki.chatterino.com).
Contribution guidelines can be found [here](https://wiki.chatterino.com/contributing). Contribution guidelines can be found [here](https://wiki.chatterino.com/contributing).
## Download ## Download
Current releases are available at [https://chatterino.com](https://chatterino.com). Current releases are available at [https://chatterino.com](https://chatterino.com).
Windows users can also install Chatterino [from Chocolatey](https://chocolatey.org/packages/chatterino). Windows users can also install Chatterino [from Chocolatey](https://chocolatey.org/packages/chatterino).
## Nightly build ## Nightly build
You can download the latest Chatterino 2 build over [here](https://github.com/Chatterino/chatterino2/releases/tag/nightly-build) You can download the latest Chatterino 2 build over [here](https://github.com/Chatterino/chatterino2/releases/tag/nightly-build)
You might also need to install the [VC++ 2017 Redistributable](https://aka.ms/vs/15/release/vc_redist.x64.exe) from Microsoft if you do not have it installed already. You might also need to install the [VC++ 2017 Redistributable](https://aka.ms/vs/15/release/vc_redist.x64.exe) from Microsoft if you do not have it installed already.
If you still receive an error about `MSVCR120.dll missing`, then you should install the [VC++ 2013 Restributable](https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe If you still receive an error about `MSVCR120.dll missing`, then you should install the [VC++ 2013 Restributable](https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe).
).
## Building ## Building
To get source code with required submodules run: To get source code with required submodules run:
``` ```
git clone --recurse-submodules https://github.com/Chatterino/chatterino2.git git clone --recurse-submodules https://github.com/Chatterino/chatterino2.git
``` ```
or or
``` ```
git clone https://github.com/Chatterino/chatterino2.git git clone https://github.com/Chatterino/chatterino2.git
cd chatterino2 cd chatterino2
@ -38,9 +43,11 @@ git submodule update --init --recursive
[Building on FreeBSD](../master/BUILDING_ON_FREEBSD.md) [Building on FreeBSD](../master/BUILDING_ON_FREEBSD.md)
## Code style ## Code style
The code is formatted using clang format in Qt Creator. [.clang-format](src/.clang-format) contains the style file for clang format. The code is formatted using clang format in Qt Creator. [.clang-format](src/.clang-format) contains the style file for clang format.
### Get it automated with QT Creator + Beautifier + Clang Format ### Get it automated with QT Creator + Beautifier + Clang Format
1. Download LLVM: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/LLVM-11.0.0-win64.exe 1. Download LLVM: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/LLVM-11.0.0-win64.exe
2. During the installation, make sure to add it to your path 2. During the installation, make sure to add it to your path
3. In QT Creator, select `Help` > `About Plugins` > `C++` > `Beautifier` to enable the plugin 3. In QT Creator, select `Help` > `About Plugins` > `C++` > `Beautifier` to enable the plugin
@ -52,4 +59,5 @@ The code is formatted using clang format in Qt Creator. [.clang-format](src/.cla
Qt creator should now format the documents when saving it. Qt creator should now format the documents when saving it.
## Doxygen ## Doxygen
Doxygen is used to generate project information daily and is available [here](https://doxygen.chatterino.com). Doxygen is used to generate project information daily and is available [here](https://doxygen.chatterino.com).

View file

@ -1,134 +1,154 @@
# Twitch API # Twitch API
this folder describes what sort of API requests we do, what permissions are required for the requests etc this folder describes what sort of API requests we do, what permissions are required for the requests etc
## Kraken (V5) ## Kraken (V5)
We use a bunch of Kraken (V5) in Chatterino2. We use a bunch of Kraken (V5) in Chatterino2.
### Get Cheermotes ### Get Cheermotes
URL: https://dev.twitch.tv/docs/v5/reference/bits#get-cheermotes URL: https://dev.twitch.tv/docs/v5/reference/bits#get-cheermotes
Migration path: **Not checked** Migration path: **Not checked**
* We implement this API in `providers/twitch/TwitchChannel.cpp` to resolve a chats available cheer emotes. This helps us parse incoming messages like `pajaCheer1000` - We implement this API in `providers/twitch/TwitchChannel.cpp` to resolve a chats available cheer emotes. This helps us parse incoming messages like `pajaCheer1000`
### Get User Emotes ### Get User Emotes
URL: https://dev.twitch.tv/docs/v5/reference/users#get-user-emotes URL: https://dev.twitch.tv/docs/v5/reference/users#get-user-emotes
Requires `user_subscriptions` scope Requires `user_subscriptions` scope
Migration path: **Unknown** Migration path: **Unknown**
* We use this in `providers/twitch/TwitchAccount.cpp loadEmotes` to figure out which emotes a user is allowed to use! - We use this in `providers/twitch/TwitchAccount.cpp loadEmotes` to figure out which emotes a user is allowed to use!
### AUTOMOD APPROVE ### AUTOMOD APPROVE
**Unofficial** documentation: https://discuss.dev.twitch.tv/t/allowing-others-aka-bots-to-use-twitchbot-reject/8508/2 **Unofficial** documentation: https://discuss.dev.twitch.tv/t/allowing-others-aka-bots-to-use-twitchbot-reject/8508/2
* We use this in `providers/twitch/TwitchAccount.cpp autoModAllow` to approve an automod deny/allow question - We use this in `providers/twitch/TwitchAccount.cpp autoModAllow` to approve an automod deny/allow question
### AUTOMOD DENY ### AUTOMOD DENY
**Unofficial** documentation: https://discuss.dev.twitch.tv/t/allowing-others-aka-bots-to-use-twitchbot-reject/8508/2 **Unofficial** documentation: https://discuss.dev.twitch.tv/t/allowing-others-aka-bots-to-use-twitchbot-reject/8508/2
* We use this in `providers/twitch/TwitchAccount.cpp autoModDeny` to deny an automod deny/allow question - We use this in `providers/twitch/TwitchAccount.cpp autoModDeny` to deny an automod deny/allow question
## Helix ## Helix
Full Helix API reference: https://dev.twitch.tv/docs/api/reference Full Helix API reference: https://dev.twitch.tv/docs/api/reference
### Get Users ### Get Users
URL: https://dev.twitch.tv/docs/api/reference#get-users URL: https://dev.twitch.tv/docs/api/reference#get-users
* We implement this in `providers/twitch/api/Helix.cpp fetchUsers`. - We implement this in `providers/twitch/api/Helix.cpp fetchUsers`.
Used in: Used in:
* `UserInfoPopup` to get ID, viewCount, displayName, createdAt of username we clicked - `UserInfoPopup` to get ID, viewCount, displayName, createdAt of username we clicked
* `CommandController` to power any commands that need to get a user ID - `CommandController` to power any commands that need to get a user ID
* `Toasts` to get the profile picture of a streamer who just went live - `Toasts` to get the profile picture of a streamer who just went live
* `TwitchAccount` block and unblock features to translate user name to user ID - `TwitchAccount` block and unblock features to translate user name to user ID
### Get Users Follows ### Get Users Follows
URL: https://dev.twitch.tv/docs/api/reference#get-users-follows URL: https://dev.twitch.tv/docs/api/reference#get-users-follows
* We implement this in `providers/twitch/api/Helix.cpp fetchUsersFollows` - We implement this in `providers/twitch/api/Helix.cpp fetchUsersFollows`
Used in: Used in:
* `UserInfoPopup` to get number of followers a user has - `UserInfoPopup` to get number of followers a user has
### Get Streams ### Get Streams
URL: https://dev.twitch.tv/docs/api/reference#get-streams URL: https://dev.twitch.tv/docs/api/reference#get-streams
* We implement this in `providers/twitch/api/Helix.cpp fetchStreams` - We implement this in `providers/twitch/api/Helix.cpp fetchStreams`
Used in: Used in:
* `TwitchChannel` to get live status, game, title, and viewer count of a channel - `TwitchChannel` to get live status, game, title, and viewer count of a channel
* `NotificationController` to provide notifications for channels you might not have open in Chatterino, but are still interested in getting notifications for - `NotificationController` to provide notifications for channels you might not have open in Chatterino, but are still interested in getting notifications for
### Follow User ### Follow User
URL: https://dev.twitch.tv/docs/api/reference#create-user-follows URL: https://dev.twitch.tv/docs/api/reference#create-user-follows
Requires `user:edit:follows` scope Requires `user:edit:follows` scope
* We implement this in `providers/twitch/api/Helix.cpp followUser` - We implement this in `providers/twitch/api/Helix.cpp followUser`
Used in: Used in:
* `widgets/dialogs/UserInfoPopup.cpp` to follow a user by ticking follow checkbox in usercard - `widgets/dialogs/UserInfoPopup.cpp` to follow a user by ticking follow checkbox in usercard
* `controllers/commands/CommandController.cpp` in /follow command - `controllers/commands/CommandController.cpp` in /follow command
### Unfollow User ### Unfollow User
URL: https://dev.twitch.tv/docs/api/reference#delete-user-follows URL: https://dev.twitch.tv/docs/api/reference#delete-user-follows
Requires `user:edit:follows` scope Requires `user:edit:follows` scope
* We implement this in `providers/twitch/api/Helix.cpp unfollowUser` - We implement this in `providers/twitch/api/Helix.cpp unfollowUser`
Used in: Used in:
* `widgets/dialogs/UserInfoPopup.cpp` to unfollow a user by unticking follow checkbox in usercard - `widgets/dialogs/UserInfoPopup.cpp` to unfollow a user by unticking follow checkbox in usercard
* `controllers/commands/CommandController.cpp` in /unfollow command - `controllers/commands/CommandController.cpp` in /unfollow command
### Create Clip ### Create Clip
URL: https://dev.twitch.tv/docs/api/reference#create-clip URL: https://dev.twitch.tv/docs/api/reference#create-clip
Requires `clips:edit` scope Requires `clips:edit` scope
* We implement this in `providers/twitch/api/Helix.cpp createClip` - We implement this in `providers/twitch/api/Helix.cpp createClip`
Used in: Used in:
* `TwitchChannel` to create a clip of a live broadcast - `TwitchChannel` to create a clip of a live broadcast
### Get Channel ### Get Channel
URL: https://dev.twitch.tv/docs/api/reference#get-channel-information URL: https://dev.twitch.tv/docs/api/reference#get-channel-information
* We implement this in `providers/twitch/api/Helix.cpp getChannel` - We implement this in `providers/twitch/api/Helix.cpp getChannel`
Used in: Used in:
* `TwitchChannel` to refresh stream title - `TwitchChannel` to refresh stream title
### Create Stream Marker ### Create Stream Marker
URL: https://dev.twitch.tv/docs/api/reference/#create-stream-marker URL: https://dev.twitch.tv/docs/api/reference/#create-stream-marker
Requires `user:edit:broadcast` scope Requires `user:edit:broadcast` scope
* We implement this in `providers/twitch/api/Helix.cpp createStreamMarker` - We implement this in `providers/twitch/api/Helix.cpp createStreamMarker`
Used in: Used in:
* `controllers/commands/CommandController.cpp` in /marker command - `controllers/commands/CommandController.cpp` in /marker command
### Get User Block List ### Get User Block List
URL: https://dev.twitch.tv/docs/api/reference#get-user-block-list URL: https://dev.twitch.tv/docs/api/reference#get-user-block-list
Requires `user:read:blocked_users` scope Requires `user:read:blocked_users` scope
* We implement this in `providers/twitch/api/Helix.cpp loadBlocks` - We implement this in `providers/twitch/api/Helix.cpp loadBlocks`
Used in: Used in:
* `providers/twitch/TwitchAccount.cpp loadBlocks` to load list of blocked (blocked) users by current user - `providers/twitch/TwitchAccount.cpp loadBlocks` to load list of blocked (blocked) users by current user
### Block User ### Block User
URL: https://dev.twitch.tv/docs/api/reference#block-user URL: https://dev.twitch.tv/docs/api/reference#block-user
Requires `user:manage:blocked_users` scope Requires `user:manage:blocked_users` scope
* We implement this in `providers/twitch/api/Helix.cpp blockUser` - We implement this in `providers/twitch/api/Helix.cpp blockUser`
Used in: Used in:
* `widgets/dialogs/UserInfoPopup.cpp` to block a user via checkbox in the usercard - `widgets/dialogs/UserInfoPopup.cpp` to block a user via checkbox in the usercard
* `controllers/commands/CommandController.cpp` to block a user via "/block" command - `controllers/commands/CommandController.cpp` to block a user via "/block" command
### Unblock User ### Unblock User
URL: https://dev.twitch.tv/docs/api/reference#unblock-user URL: https://dev.twitch.tv/docs/api/reference#unblock-user
Requires `user:manage:blocked_users` scope Requires `user:manage:blocked_users` scope
* We implement this in `providers/twitch/api/Helix.cpp unblockUser` - We implement this in `providers/twitch/api/Helix.cpp unblockUser`
Used in: Used in:
* `widgets/dialogs/UserInfoPopup.cpp` to unblock a user via checkbox in the usercard - `widgets/dialogs/UserInfoPopup.cpp` to unblock a user via checkbox in the usercard
* `controllers/commands/CommandController.cpp` to unblock a user via "/unblock" command - `controllers/commands/CommandController.cpp` to unblock a user via "/unblock" command
## TMI ## TMI
The TMI api is undocumented. The TMI api is undocumented.
### Get Chatters ### Get Chatters
**Undocumented** **Undocumented**
* We use this in `widgets/splits/Split.cpp showViewerList` - We use this in `widgets/splits/Split.cpp showViewerList`
* We use this in `providers/twitch/TwitchChannel.cpp refreshChatters` - We use this in `providers/twitch/TwitchChannel.cpp refreshChatters`