You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+51-18Lines changed: 51 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,15 +90,17 @@ The project is not intended necessarily to be run in a container or a specific I
90
90
-`meta` directory currently contains 3 [draw.io](https://www.drawio.com/) diagram files about the project, and a `google-style-eclipse.xml` file used in Spotless configuration.
91
91
-`scripts` directory currently contains only one file which is a git pre-commit hook that runs Spotless to format the code before committing.
92
92
93
-
## Application
93
+
### Module 1: Application
94
94
95
95
This is the main module. It contains the entry point, core logic, feature implementations, configuration management, and logging utilities for the bot.
96
96
97
97
Most packages are equipped with a `package-info.java` file, which contains a brief description and 2 annotations
98
98
-`@MethodsReturnNonnullByDefault`: defined in the `/utils` module, indicating that all methods in the package return non-null values by default.
99
99
-`@ParametersAreNonnullByDefault`: from `javax.annotation` package, indicating that all parameters in the package are non-null by default.
100
100
101
-
### 1. `config`:
101
+
NOTE: _We recommend to all contributors to only focus on this module. The other ones are handling some aspects behind the scenes, and are not meant to be modified by contributors._
102
+
103
+
#### 1. `config`:
102
104
103
105
Purpose: Handles all configuration aspects of the bot, including loading, validating, and providing access to configuration values.
104
106
@@ -107,7 +109,7 @@ Contents:
107
109
- Utilities for environment variable overrides and runtime configuration changes.
108
110
- Central access point for configuration values used throughout the application.
109
111
110
-
### 2. `features`
112
+
####2. `features`
111
113
112
114
Purpose: Implements the bot’s features, including commands, event listeners, and integrations.
113
115
@@ -117,7 +119,7 @@ Contents:
117
119
- Feature registration and lifecycle management (e.g., Features.createFeatures).
118
120
- Sub-packages for organizing features by domain (e.g., basic, chatgpt (openai), code, projects, and others).
119
121
120
-
### 3. `logging`
122
+
####3. `logging`
121
123
122
124
Purpose: Provides logging configuration and utilities for the application.
123
125
@@ -126,15 +128,56 @@ Contents:
126
128
- Custom logging utilities and wrappers.
127
129
- Integration with `SLF4J` for consistent logging across dependencies.
128
130
131
+
### Module 2: BuildSrc
132
+
133
+
This module doesn't contain any Java files, it contains a build process to the SQLite database using Flyway and JOOQ.
134
+
135
+
It contains exactly one groovy file database-settings.gradle, which is a custom Gradle plugin that handles the database schema generation and migration.
136
+
137
+
### Module 3: Database
138
+
139
+
This module is about creating the connection to the SQLite database and providing a way to interact with it using JOOQ.
140
+
141
+
### Module 4: Formatter
142
+
143
+
This module is about formatting code snippets in Discord messages, using the JDA library.
144
+
145
+
It's a sort of support for the `features.code` package in the `application` module.
146
+
147
+
> formatter... is a really complex project. it was created as its own module. probably also bc it was originally intended to be run outside the bots context - Zabuzard
148
+
149
+
### Module 5: Utils
150
+
151
+
This module contains utility classes and methods that are used across the application. It includes exactly one class `MethodsReturnNonnullByDefault` which is an annotation used in most packages in the `application` module.
152
+
129
153
## Complex Aspects
130
154
131
-
## Security
155
+
This section is about some important aspects in the `application` module. Some of these aspects are complex and may require additional attention when they get modified :
156
+
157
+
-`BotCore` a class/component defined under a subpackage `features.system`.
158
+
-`ComponentIdStore` under a subpackage `features.componentids`.
159
+
-`ComponentIdGenerator` under a subpackage `features.componentids`.
160
+
-`ComponentIdInteractor` under a subpackage `features.componentids`.
161
+
-`ComponentIdParser` under a subpackage `features.componentids`.
162
+
-`Lifespan` under a subpackage `features.componentids`.
163
+
- The corresponding database table and how it hooks into the actions, i.e. `UserInteractor#acceptComponmentIdGenerator` and the like.
164
+
- the unit testing setup around discord mocking: the `JdaTester` class and the files next to it (.e.g the `jda.payloads` package)
165
+
166
+
NOTE: _These aspects are not meant to be modified by contributors, but they are important to understand how the bot works._
132
167
133
168
## Coding Style
169
+
170
+
This section outlines the coding style and conventions to follow when contributing to the project. Adhering to these guidelines ensures consistency and readability across the codebase.
171
+
172
+
Know that the organization uses [Sonar](https://sonarcloud.io/project/overview?id=Together-Java_TJ-Bot) and Spotless to enforce coding style and formatting rules.
173
+
174
+
Try to use the [Together-Java Sonar's Quality Profile](https://sonarcloud.io/organizations/togetherjava/quality_profiles) when you write code or help with completions.
175
+
176
+
In addition, the following conventions should be followed:
134
177
- Use meaningful variable and method names.
135
178
- Use `@Override` annotation for overridden methods.
136
-
- Use `final` for fields and classes.
137
-
-Use`this` keyword to refer to the current instance of a class.
179
+
- Use `final` for fields and classes whenever is better.
180
+
-Enforce using`this` keyword to refer to the current instance of a class.
138
181
- No magic numbers or strings; use constants instead.
139
182
- No unnecessary comments; code should be self-explanatory.
140
183
- Use Javadoc for public classes and methods.
@@ -176,14 +219,4 @@ public static Collection<Feature> createFeatures(JDA jda, Database database, Con
0 commit comments