GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [apex] bad support for multiline SOQL in cpd · Issue #838 · pmd/pmd

[apex] bad support for multiline SOQL in cpd #838

New issue
Copy link
New issue
Copy link
Open
Open
[apex] bad support for multiline SOQL in cpd#838
Copy link
Labels
in:cpdAffects the copy-paste detector

Description

@Bartheleway
Bartheleway
opened on Jan 10, 2018
Issue body actions

PMD Version: 6.0.0

Description: When you write your SOQL on multiple lines and running the cpd command, it will log false positive of duplicate code.

Code Sample demonstrating the issue:

List<Account> accountList = [
    SELECT
        Id,
        Name,
        Site
    FROM
        Account
    WHERE
        Id IN :myIdList
];
List<Account> accountList2 = [
    SELECT
        Id,
        Name,
        Site
    FROM
        Account
    WHERE
        CreatedDate < TODAY
];

Running PMD through: cmd

PMD Result:

Found a 8 line (x tokens) duplication in the following files:
Starting at line 2 of myFile.cls
Starting at line 12 of myFile.cls

    List<Account> accountList2 = [
        SELECT
            Id,
            Name,
            Site
        FROM
            Account
        WHERE

NB: if you run my example as it is, you won't get my result because I minimized the number of selected fields for the example. I think it shouldn't evaluate each line but the SOQL as a whole.
And also my code is totally stupid and only made for the example (if you wonder why).

Activity

  1. jsotuyod commented on Jan 10, 2018

    @jsotuyod
    jsotuyod
    on Jan 10, 2018
    Member
    More actions

    Interesting... we are using the ApexLexer from jorje, so they are the ones splitting the SOQL into tokens... we may rebuild it as a single "token" for the whole SOQL on top of that, but we'd have to evaluate if this approach doesn't introduce any unwanted byproducts...

  2. jsotuyod
    added
    in:cpdAffects the copy-paste detector
    on Jan 9, 2019
  3. adangel
    added
    needs:pmd7-revalidationThe issue hasn't yet been retested vs PMD 7 and may be stale
    on May 3, 2024
  4. adangel commented on Jan 29, 2026

    @adangel
    adangel
    on Jan 29, 2026
    Member
    More actions

    Can still be reproduced with 7.21.0.

  5. adangel
    removed
    needs:pmd7-revalidationThe issue hasn't yet been retested vs PMD 7 and may be stale
    on Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in:cpdAffects the copy-paste detector

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.