Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Don't repeat the log level in the message text
Drop manual '[INFO]'/'[ERROR]' prefixes from log messages; the logger already records the level.
Bad example
| 1 | logger.info('[INFO]: No files to process!'); |
| 2 | logger.error('[ERROR]: Failed to save to index'); |
Explanation (EN)
The logger already tags each entry with its level, so hardcoding '[INFO]'/'[ERROR]' duplicates information, clutters the message, and drifts out of sync if someone changes the log method without updating the text.
Objašnjenje (HR)
Logger vec oznacava svaki zapis razinom, pa hardkodiranje '[INFO]'/'[ERROR]' duplicira informaciju, zatrpava poruku i razilazi se ako netko promijeni metodu logiranja a ne azurira tekst.
Good example
| 1 | logger.info('No files to process!'); |
| 2 | logger.error('Failed to save to index'); |
Explanation (EN)
Let the logging level convey severity and keep the message focused on what happened, which also keeps log filtering and formatting consistent.
Objašnjenje (HR)
Neka razina logiranja prenosi ozbiljnost, a poruka neka ostane fokusirana na to sto se dogodilo, sto ujedno cuva dosljedno filtriranje i formatiranje logova.