|
1 | | -# Code Health and Style Guide Adherence Log |
| 1 | +# Code Health and Style Guide Analysis |
2 | 2 |
|
3 | | -This document tracks the ongoing effort to maintain code health and ensure all samples align with the official Flutter style guide. This workflow is performed periodically by an AI assistant. |
| 3 | +This document provides instructions for an AI assistant to analyze this repository against the Dart and Flutter style guide (`.prompts/llm.md`) and log opportunities for improvement. |
4 | 4 |
|
5 | 5 | ## Workflow |
6 | 6 |
|
7 | | -The AI assistant performs the following steps for **each sample project** in the repository: |
| 7 | +The AI assistant must follow these steps exactly: |
8 | 8 |
|
9 | | -1. **Analyze Git History:** |
10 | | - * Use `git log` to find the most recent commit to a `.dart` file within that sample's directory that was made by a human (i.e., not a bot). |
11 | | - * **Example command for a sample in `sample_name/`:** |
| 9 | +### 1. Setup |
| 10 | + |
| 11 | +1. **Create Log Directory**: If it does not already exist, create a directory named `logs` in the repository root. |
| 12 | +2. **Create Log File**: Create a new file inside the `logs` directory named `YYYY-MM-DD_HH-MM-SS-freshness-scores.md`, where `YYYY-MM-DD_HH-MM-SS` is the current timestamp. |
| 13 | + |
| 14 | +### 2. Project Identification |
| 15 | + |
| 16 | +1. **Find Projects**: Identify all sample projects by searching for `pubspec.yaml` files within the repository. Each directory containing a `pubspec.yaml` should be considered a separate project. |
| 17 | +2. **Create a Queue**: Compile a list of the absolute paths to these project directories to process them one by one. |
| 18 | + |
| 19 | +### 3. Analysis Loop |
| 20 | + |
| 21 | +For each project directory identified in the previous step, perform the following: |
| 22 | + |
| 23 | +1. **Check for Dart Files**: |
| 24 | + * Verify that the project directory contains at least one `.dart` file. |
| 25 | + * If not, add an entry to the log file stating that the project was skipped for this reason and proceed to the next project. |
| 26 | + |
| 27 | +2. **Analyze Git History**: |
| 28 | + * Run `git log` to find the most recent commit to a `.dart` file within that project's directory made by a human (i.e., not a bot). |
| 29 | + * **Command**: |
12 | 30 | ```bash |
13 | | - git log -1 --author='^(?!.*bot).*$' --pretty="format:%ad" --date=short -- ./sample_name/**/*.dart |
| 31 | + git log -1 --author='^(?!.*bot).*$' --pretty="format:%ad" --date=short -- ./**/*.dart |
14 | 32 | ``` |
15 | | - * Parse the output to get the date of the last human commit. |
16 | | - |
17 | | -2. **Analyze the Code:** The assistant reads all the relevant `.dart` files within the selected sample's directory. |
18 | | -
|
19 | | -3. **Assess Against Style Guide:** The assistant compares the code against the rules and patterns defined in `llm.md`. The assessment focuses on: |
20 | | - * Code organization and structure. |
21 | | - * Adherence to naming conventions. |
22 | | - * Proper use of Flutter and Dart patterns. |
23 | | - * State management best practices. |
24 | | - * Clarity, readability, and documentation. |
25 | | -
|
26 | | -4. **Log Findings:** The assistant creates or updates the log entry for the sample. The log entry must include: |
27 | | - * The sample name. |
28 | | - * The date of the last human commit. |
29 | | - * The date of the AI assessment. |
30 | | - * A summary of the style guide adherence. |
31 | | - * A concrete, actionable list of opportunities for improvement. |
32 | | -
|
33 | | ---- |
34 | | -
|
35 | | -## Sample Assessments |
36 | | -
|
37 | | -### sample: `provider_shopper` |
38 | | -
|
39 | | -* **Last Human Commit:** 2024-11-20 |
40 | | -* **Last AI Assessment:** 2025-08-08 |
41 | | -* **Style Guide Adherence:** Good. The sample generally follows the recommended provider patterns and naming conventions. Documentation is present for most public members. |
42 | | -* **Improvement Opportunities:** |
43 | | - * **[Refactor]** In `lib/models/cart.dart`, the `add` method could be simplified using a collection-if in the list literal. |
44 | | - * **[Style]** Some private members in `lib/models/catalog.dart` are missing the leading underscore. |
45 | | - * **[Doc]** The top-level `main` function in `lib/main.dart` is missing a doc comment. |
46 | | -
|
47 | | -### sample: `animations` |
48 | | -
|
49 | | -* **Last Human Commit:** 2024-05-12 |
50 | | -* **Last AI Assessment:** 2025-08-08 |
51 | | -* **Style Guide Adherence:** Fair. The sample effectively demonstrates the animations library, but some older patterns are used. The code could be more readable with modern Dart features. |
52 | | -* **Improvement Opportunities:** |
53 | | - * **[Clarity]** In `lib/main.dart`, the `build` method for the main widget is over 300 lines long. It should be broken down into smaller, more manageable private widget classes. |
54 | | - * **[Pattern]** The code uses `Future.then()` in a few places. These should be updated to use `async/await` for better readability. |
55 | | - * **[Naming]** Several variables use abbreviations (e.g., `btn` instead of `button`). These should be renamed for clarity. |
| 33 | + *(Note: This command should be run from within the project's directory).* |
| 34 | + * **Handle No Commits**: If the command returns no output, note "No human commits found" for the log. If there are no commits at all, note that as well. |
| 35 | +
|
| 36 | +3. **Read and Assess Code**: |
| 37 | + * Read all `.dart` files within the project directory (recursively). |
| 38 | + * Compare the code against the rules and patterns defined in `.prompts/llm.md`. |
| 39 | + * The assessment must focus on: |
| 40 | + * Code organization and structure. |
| 41 | + * Adherence to naming conventions. |
| 42 | + * Proper use of Flutter and Dart patterns (e.g., `const` constructors, collection literals). |
| 43 | + * State management best practices. |
| 44 | + * Clarity, readability, and documentation. |
| 45 | +
|
| 46 | +4. **Log Findings**: |
| 47 | + * Append a new entry to the log file using the following Markdown template. Ensure all fields are filled out. |
| 48 | +
|
| 49 | + ```markdown |
| 50 | + --- |
| 51 | + **Sample**: `path/to/sample` |
| 52 | + **Last Human Commit**: `YYYY-MM-DD` or "No human commits found" |
| 53 | + **Assessment Date**: `YYYY-MM-DD` |
| 54 | +
|
| 55 | + **Summary of Style Guide Adherence**: |
| 56 | + A brief, one-paragraph summary of how well the project adheres to the style guide. Mention its strengths and weaknesses in general terms. |
| 57 | +
|
| 58 | + **Opportunities for Improvement**: |
| 59 | + - A concrete, actionable bullet point describing a specific area for improvement. |
| 60 | + - Another actionable bullet point. |
| 61 | + - A third bullet point, if applicable. Focus on providing clear, specific, and helpful recommendations. |
| 62 | + --- |
| 63 | + ``` |
0 commit comments