mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-07-14 04:28:10 +00:00
updated pr-agent best practices with auto analysis
parent
75e0670493
commit
43a739599a
|
@ -1,3 +1,49 @@
|
||||||
|
<!-- PR --><table><tr><td> <b><a href='3006712754'>PR 279</a></b> (2025-06-26)
|
||||||
|
|
||||||
|
</td></tr></table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- suggestion --><details><summary>[possible issue] Fix null reference exception risk</summary>
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
✅ Fix null reference exception risk
|
||||||
|
|
||||||
|
**The null check for schema should occur before accessing schema.PrimaryKey to prevent potential null reference exceptions. Move the null validation to the beginning of the constructor.**
|
||||||
|
|
||||||
|
[WelsonJS.Toolkit/WelsonJS.Esent/EsentDatabase.cs [35-41]](https://github.com/gnh1201/welsonjs/pull/279/files#diff-21f279a29d8eeede6f37b552960fc5b0aef7c187c40481256398bd8a318f5590R35-R41)
|
||||||
|
|
||||||
|
```diff
|
||||||
|
public EsentDatabase(Schema schema, string workingDirectory, ICompatibleLogger logger = null)
|
||||||
|
{
|
||||||
|
+ if (schema == null)
|
||||||
|
+ throw new ArgumentNullException(nameof(schema));
|
||||||
|
+
|
||||||
|
_logger = logger ?? new TraceLogger();
|
||||||
|
-
|
||||||
|
_primaryKey = schema.PrimaryKey;
|
||||||
|
|
||||||
|
- if (schema == null)
|
||||||
|
-
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Suggestion importance[1-10]: 9
|
||||||
|
|
||||||
|
__
|
||||||
|
|
||||||
|
Why: The suggestion correctly identifies a critical bug. The code accesses `schema.PrimaryKey` before checking if `schema` is null, which would lead to a `NullReferenceException` if a null schema is provided. Moving the validation to the start of the constructor is the correct way to fix this.
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- PR --><table><tr><td> <b><a href='2982794401'>PR 276</a></b> (2025-06-18)
|
<!-- PR --><table><tr><td> <b><a href='2982794401'>PR 276</a></b> (2025-06-18)
|
||||||
|
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
@ -39,6 +85,8 @@ ___
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- PR --><table><tr><td> <b><a href='2953770469'>PR 272</a></b> (2025-06-08)
|
<!-- PR --><table><tr><td> <b><a href='2953770469'>PR 272</a></b> (2025-06-08)
|
||||||
|
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
@ -90,6 +138,8 @@ ___
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- PR --><table><tr><td> <b><a href='2868572186'>PR 249</a></b> (2025-05-10)
|
<!-- PR --><table><tr><td> <b><a href='2868572186'>PR 249</a></b> (2025-05-10)
|
||||||
|
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
@ -152,6 +202,8 @@ ___
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- PR --><table><tr><td> <b><a href='2868568893'>PR 248</a></b> (2025-05-10)
|
<!-- PR --><table><tr><td> <b><a href='2868568893'>PR 248</a></b> (2025-05-10)
|
||||||
|
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
@ -271,6 +323,8 @@ ___
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- PR --><table><tr><td> <b><a href='2850302530'>PR 245</a></b> (2025-05-05)
|
<!-- PR --><table><tr><td> <b><a href='2850302530'>PR 245</a></b> (2025-05-05)
|
||||||
|
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
@ -359,6 +413,8 @@ ___
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- PR --><table><tr><td> <b><a href='2832883684'>PR 242</a></b> (2025-04-27)
|
<!-- PR --><table><tr><td> <b><a href='2832883684'>PR 242</a></b> (2025-04-27)
|
||||||
|
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user