pmd / pmd/pmd

[apex] Type declaration/casts/constructors have correct capitalization

Open
#4,112 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

a:new-rule
Dominant language
Java
Stars
5.5k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
54

Description

Proposed Rule Name: Type has correct capitalization

Proposed Category: [Code Style]

Description:
Check if Type declaration and constructors have proper capitalization according to SFDX class cache.
Alternatively if not possible to implement at least that the Type conforms to the class naming regexp.

Also it might be good idea to split this into 2 rules -> 1 for constructors and 1 for Type declarations. (or maybe to 3 -> 1 for type casts).

Code Sample:

string s1; // gets flagged
String s2; // ok

account a1; // gets flagged
Account a2; // ok

Account a3 = new account(); // gets flagged
Account a4 = new Account(); // ok

list<Account> accounts1; //gets flagged
List<account> accounts2; // gets flagged
List<Account> accounts3; // OK

List<Account> accounts4 = (List<account>) new List<SObject>(); // gets flagged
List<Account> accounts5 = (List<Account>) new List<SObject>(); // gets flagged

Possible Properties:

  • can PMD check other files in the hierarchy? (as the list of classes with proper names is generated with SFDX)
  • it could be useful for some teams to be able to pass the list of sObjects & classes (with proper capitalization) or just regex

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named in the issue. Start by locating the Apex rule implementation and determine how type declarations, casts, and constructors are represented; done means the proposed examples are classified correctly and the source of valid capitalization is defined.

Written by the indexing model from the issue text.

Assessment

Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.