Base Code Analyzer Metrics
Overview
The Base Code Analyzer outputs metrics with the following severities:
| Severity | Description |
|---|---|
| ❗ Error | Critical issue that must be fixed |
| ⚠️ Warning | Potentially critical issue that should be fixed |
| 💡 Suggestion | A potential error / warning that can't be verified programmatically or a suggested improvement |
Metrics
The following metrics are analyzed by the C3 AI Code Analyzer:
- PSR Anti-Patterns
- Documentation
- Training
- Linting
- Tech Debt
- Security
- Deprecations
- Extensibility Anti-Patterns
PSR Anti-Patterns
c3-psr-unlimited-fetch
- Name: fetch limit -1
- Description:
- Identifies invocations of
fetchwith limit -1. - An unlimited
fetchcould cause production outages by causing the JVM to run out of memory.
- Identifies invocations of
- Applies to:
.js,.py - Severities: ⚠️ warning, ❗ error
c3-psr-unfiltered-remove-all
- Name:
removeAllwithout a filter - Description:
- Identifies invocations of
removeAllwithout a filter. - Unfiltered
removeAllcould cause production data to be deleted inadvertently.
- Identifies invocations of
- Applies to:
.js,.py - Severities: ⚠️ warning, ❗ error
c3-psr-clear-collection
- Name: Unsafe invocation of
clearCollectioncall - Description:
- Identifies invocations of
clearCollection. clearCollectionis an unfilteredremoveAlland could cause production data to be deleted inadvertently.
- Identifies invocations of
- Applies to:
.js,.py - Severities: ❗ error
c3-psr-loop-single-db-write
- Name: Single database write in a loop
- Description:
- Identifies invocations of
create,merge,upsert, orremovein a loop. - Single database write operations in a loop are less efficient than their batch write operation counterparts.
- Identifies invocations of
- Applies to:
.js,.py - Severities: ❗ error
c3-psr-kv-stored-calc-field
- Name: Stored Calc Field on Key-Value Type
- Description:
- Identifies stored calc declarations on kv-store Types.
- Data in kv-datastores can be high-volume and/or frequently invalidated, causing the
CalcFieldsQueueto become congested.
- Applies to:
.c3typ - Severities: ⚠️ warning, ❗ error
c3-psr-sleep-call
- Name:
time.sleep()orThread.sleep()call - Description:
- Identifies invocations of
time.sleep()orThread.sleep()in code. time.sleep()orThread.sleep()calls introduce a built-in race condition.
- Identifies invocations of
- Applies to:
.js,.py - Severities: ❗ error
Documentation
c3-missing-docs
- Name: Missing Documentation
- Description:
- Identifies undocumented Types, fields, and APIs.
- Documentation is critical to the usability and maintainability of a package. All Types, fields, and APIs must be documented.
- Applies to:
.c3typ - Severities: ❗ error
c3-incomplete-method-docs
- Name: Incomplete Method Documentation
- Description:
- Identifies undocumented parameters and returns on APIs.
- Documenting all API parameters and returns is important to ensure consumers are aware of limitations, assumptions, and treatments of inputs/outputs to the API.
- Applies to:
.c3typ - Severities: ⚠️ warning
c3-todos-in-type-docs
- Name: Ticket Mentions in Type Documentation
- Description:
- Identifies Jira ticket mentions visible in customer-facing documentation.
- Jira tickets are purely internal and shouldn't be visible to customers.
- Applies to:
.c3typ - Severities: ❗ error
c3-broken-doc-links
- Name: Broken Documentation Links
- Description:
- Identifies broken documentation links.
- All links in documentation should point to valid Types, topics, and external web pages.
- Applies to:
.c3typ,.c3doc.md - Severities: 💡 suggestion, ❗ error
c3-orphaned-docs
- Name: Orphaned Documentation
- Description:
- Identifies
.c3doc.mdfiles that aren't referenced in a guide. - Topics not referenced in a guide aren't discoverable on the documentation site.
- Identifies
- Applies to:
.c3typ,.c3doc.md - Severities: ⚠️ warning, ❗ error
c3-missing-pkg-overview
- Name: Missing Package Overview
- Description:
- Identifies packages that don't have a package overview.
- All packages must include an overview page to help consumers identify its purpose and capabilities.
- Applies to:
.c3doc.md - Severities: ⚠️ warning, ❗ error
Training
c3-tutorial-notebook-execution
- Name: Tutorial Notebook Execution
- Description:
- Detects instances of out-of-order cell execution in seeded tutorial notebooks.
- Applies to:
.ipynb - Severities: ❗ error
Linting
c3-eslint
- Name: ESLint
- Description:
- Identifies ESLint warnings and errors in code.
- All JavaScript and TypeScript should follow industry standards and conventions.
- Applies to:
.js,.ts - Severities: ⚠️ warning, ❗ error
c3-python-lint
- Name: Python Lint
- Description:
- Identifies
pylintwarnings and errors in code. - All Python should follow industry standards and conventions.
- Identifies
- Applies to:
.py - Severities: ⚠️ warning, ❗ error
Technical Debt
c3-unticketed-todos
- Name: Unticketed TODOs / FIXMEs
- Description:
- Identifies
TODOorFIXMEreferences in code that don't have an associated ticket. - All pending items must include an accompanying ticket to address the action item.
- Identifies
- Applies to:
.c3typ,.js,.py - Severities: ❗ error
Security
c3-hardcoded-credentials
- Name: Hardcoded Credentials
- Description:
- Identifies any hardcoded credentials in code.
- Credentials must be stored in and referenced from a secret vault.
- Applies to:
.js,.py - Severities: ❗ error
Deprecations
c3-expired-deprecations
- Name: Expired Deprecations
- Description:
- Identifies
@deprecatedTypes, fields, and APIs that have passed their final version. - Deprecated Types, fields, and APIs must be removed one major version after their final version.
- Identifies
- Applies to:
.c3typ - Severities: ⚠️ warning, ❗ error
c3-deprecated-type-usage
- Name: Deprecated Type Usage
- Description:
- Identifies the usage of a
@deprecatedType. - Usage of
@deprecatedType must be refactored to use the prescribed alternative.
- Identifies the usage of a
- Applies to:
.js,.py - Severities: ❗ error
Extensibility Anti-Patterns
c3-hidden-funcs
- Name: Hidden Functions
- Description:
- Identifies functions in code that aren't exposed on the target Type.
- Relevant hidden functions must be exposed on the target Type to allow consumers to override implementations.
- Applies to:
.js,.py - Severities: 💡 suggestion
c3-excessive-method-params
- Name: Too Many Parameters
- Description:
- Identifies APIs with an excessive number of parameters.
- Functions with too many parameters can be difficult to use and maintain.
- Applies to:
.c3typ - Severities: ⚠️ warning