enh(tools): enhance robot tests generator#6216
Open
omercier wants to merge 3 commits into
Open
Conversation
scresto31
reviewed
Jun 15, 2026
Comment on lines
+196
to
+197
| # Import constants for counter types and kinds | ||
| use centreon::plugins::constants qw(:counter_types :counter_kinds); |
Contributor
There was a problem hiding this comment.
Suggested change
| # Import constants for counter types and kinds | |
| use centreon::plugins::constants qw(:counter_types :counter_kinds); | |
| # Import constants for counter types, kinds and skipped values | |
| use centreon::plugins::constants qw(:counters :values); |
Comment on lines
198
to
199
| # We will have to process some JSON, no need to reinvent the wheel, load the lib you installed in a previous section | ||
| use JSON::XS; |
Contributor
There was a problem hiding this comment.
Suggested change
| # We will have to process some JSON, no need to reinvent the wheel, load the lib you installed in a previous section | |
| use JSON::XS; | |
| # We need to process some JSON. No need to reinvent the wheel: | |
| # use the available functions provided by misc.pm, such as | |
| # json_encode() and json_decode(). | |
| use centreon::plugins::misc qw/json_encode json_decode/; |
| # Needed libraries | ||
| use strict; | ||
| use warnings; | ||
| use centreon::plugins::constants qw(:counter_types); |
Contributor
There was a problem hiding this comment.
Suggested change
| use centreon::plugins::constants qw(:counter_types); | |
| use centreon::plugins::constants qw(:counters); |
| ```perl | ||
| use centreon::plugins::constants qw(:counter_types); |
Contributor
There was a problem hiding this comment.
Suggested change
| use centreon::plugins::constants qw(:counter_types); | |
| use centreon::plugins::constants qw(:counters); |
|
|
||
| use strict; | ||
| use warnings; | ||
| use centreon::plugins::constants qw(:counter_types); |
Contributor
There was a problem hiding this comment.
Suggested change
| use centreon::plugins::constants qw(:counter_types); | |
| use centreon::plugins::constants qw(:counters); |
|
|
||
| use strict; | ||
| use warnings; | ||
| use centreon::plugins::constants qw(:counter_types); |
Contributor
There was a problem hiding this comment.
Suggested change
| use centreon::plugins::constants qw(:counter_types); | |
| use centreon::plugins::constants qw(:counters); |
|
|
||
| use strict; | ||
| use warnings; | ||
| use centreon::plugins::constants qw(:counter_types); |
Contributor
There was a problem hiding this comment.
Suggested change
| use centreon::plugins::constants qw(:counter_types); | |
| use centreon::plugins::constants qw(:counters); |
| ```skipped_code => { -2 => 1, -10 => 1 }``` | ||
| This is much more understandable this way: | ||
| ```skipped_code => { NOT_PROCESSED() => 1, NO_VALUE() => 1 }``` | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| ### Use the short_msg parameter of option_exit | |
| When you need to display an error message and exit the plugin, it is simpler to use a single `option_exit` call rather than calling `add_opton_msg` followed by `option_exit`. | |
| For example: | |
| $self->{output}->option_exit(short_msg => "Cannot encode JSON result"); | |
| Instead of: | |
| $self->{output}->add_option_msg(short_msg => "Cannot encode JSON result"); | |
| $self->{output}->option_exit(); | |
| ### Use the functions provided by Misc.pm | |
| In general, before implementing something from scratch, check whether an existing function in [centreon/plugins/misc.pm](../../../src/centreon/plugins/misc.pm) already provides the required functionality. | |
| Please refer to the [misc.pm](../../../src/centreon/plugins/misc.pm) documentation for the list of available functions and examples of their usage. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs: CTOR-2336
Type of change
How this pull request can be tested ?
Please describe the procedure to verify that the goal of the PR is matched.
Provide clear instructions so that it can be correctly tested.
Mention the automated tests included in this FOR (what they test like mode/option combinations).
Checklist