Skip to content

Commit 04a5b18

Browse files
authored
Merge pull request #5838 from MetRonnie/lint
`cylc lint`: add rule to catch `rose date` usage
2 parents 9594f29 + 38ca9d6 commit 04a5b18

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

changes.d/5838.feat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`cylc lint`: added rule to check for `rose date` usage (should be replaced with `isodatetime`).

cylc/flow/scripts/lint.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,21 @@ def check_indentation(line: str) -> bool:
569569
'job-script-vars/index.html'
570570
),
571571
FUNCTION: check_for_obsolete_environment_variables,
572-
}
572+
},
573+
'U014': {
574+
'short': 'Use "isodatetime [ref]" instead of "rose date [-c]"',
575+
'rst': (
576+
'For datetime operations in task scripts:\n\n'
577+
' * Use ``isodatetime`` instead of ``rose date``\n'
578+
' * Use ``isodatetime ref`` instead of ``rose date -c`` for '
579+
'the current cycle point\n'
580+
),
581+
'url': (
582+
'https://cylc.github.io/cylc-doc/stable/html/7-to-8/'
583+
'cheat-sheet.html#datetime-operations'
584+
),
585+
FUNCTION: re.compile(r'rose +date').findall,
586+
},
573587
}
574588
RULESETS = ['728', 'style', 'all']
575589
EXTRA_TOML_VALIDATION = {

tests/unit/scripts/test_lint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
pre-script = "echo ${CYLC_SUITE_DEF_PATH}"
104104
script = {{HELLOWORLD}}
105105
post-script = "echo ${CYLC_SUITE_INITIAL_CYCLE_TIME}"
106+
env-script = POINT=$(rose date 2059 --offset P1M)
106107
[[[suite state polling]]]
107108
template = and
108109
[[[remote]]]

0 commit comments

Comments
 (0)