martin-helmich / typo3-typoscript-lint

Find coding errors in your TypoScript files.
MIT License
82 stars 19 forks source link

False positive for NestingConsistencySniff when constants are used as keys #127

Open mmunz opened 2 years ago

mmunz commented 2 years ago

I needed to use something like in a solr index.queue config to get dirrefent detail page urls depending on in which folder news are stored.

  parameter.cObject = CASE
  parameter.cObject {
      key.field = pid

      # News in storage folder 1
      {$pageUid.newsStorage1} = TEXT
      {$pageUid.newsStorage1}.value = {$pageUid.news1DetailPage}

      # News in storage folder 2
      {$pageUid.newsStorage2} = TEXT
      {$pageUid.newsStorage2}.value = {$pageUid.news2DetailPage}

      # Default news
      default = TEXT
      default.value = {$pageUid.newsDefaultDetailPage}
  }

The sniff detects those as errors:

CHECKSTYLE REPORT
=> /path/SolrNews.typoscript.
93 Common path prefix "{$pageUid" with assignments to "{$pageUid.newsStorage1}.value" in line 94, "{$pageUid.newsStorage2}" in line 97, "{$pageUid.newsStorage2}.value" in line 98. Consider merging them into a nested assignment.
94 Common path prefix "{$pageUid" with assignments to "{$pageUid.newsStorage1}" in line 93, "{$pageUid.newsStorage2}" in line 97, "{$pageUid.newsStorage2}.value" in line 98. Consider merging them into a nested assignment.
97 Common path prefix "{$pageUid" with assignments to "{$pageUid.newsStorage1}" in line 93, "{$pageUid.newsStorage1}.value" in line 94, "{$pageUid.newsStorage2}.value" in line 98. Consider merging them into a nested assignment.
98 Common path prefix "{$pageUid" with assignments to "{$pageUid.newsStorage1}" in line 93, "{$pageUid.newsStorage1}.value" in line 94, "{$pageUid.newsStorage2}" in line 97. Consider merging them into a nested assignment.

SUMMARY
4 issues in total. (4 warnings)

Maybe constants/variables as keys should be excluded in that sniff.