[coreboot-gerrit] Change in coreboot[master]: util/lint/kconfig_lint: update help checking
Martin Roth (Code Review)
gerrit at coreboot.org
Wed May 24 03:43:56 CEST 2017
Martin Roth has uploaded a new change for review. ( https://review.coreboot.org/19851 )
Change subject: util/lint/kconfig_lint: update help checking
......................................................................
util/lint/kconfig_lint: update help checking
- Turn the check for help text with no indentation from a warning to
an error.
- Show an error if the help text is at the same indentation level as
the 'help' keyword.
Change-Id: Ibf868c83e2a128ceb6c4d3da7f2cf7dc237054e6
Signed-off-by: Martin Roth <martinroth at google.com>
---
M util/lint/kconfig_lint
M util/lint/kconfig_lint_README
2 files changed, 19 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/19851/1
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index c9ccfb9..8578a7f 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -1007,26 +1007,36 @@
{
#create a non-global static variable by enclosing it and the subroutine
my $help_whitespace = ""; #string to show length of the help whitespace
+ my $help_keyword_whitespace = "";
sub handle_help {
my ( $line, $inside_help, $inside_config, $inside_choice, $filename, $line_no ) = @_;
if ($inside_help) {
+ if ($filename eq "src/mainboard/intel/glkrvp/Kconfig"){
+ print "";
+ }
+
#get the indentation level if it's not already set.
if ( ( !$help_whitespace ) && ( $line !~ /^[\r\n]+/ ) ) {
$line =~ /^(\s+)/; #find the indentation level.
$help_whitespace = $1;
if ( !$help_whitespace ) {
- show_warning("$filename:$line_no - help text starts with no whitespace.");
+ show_error("$filename:$line_no - help text starts with no whitespace.");
return $inside_help;
+ }
+ elsif ($help_keyword_whitespace eq $help_whitespace) {
+ show_error("$filename:$line_no - help text needs additional indentation.");
+ return $inside_help;
}
}
#help ends at the first line which has a smaller indentation than the first line of the help text.
- if ( ( $line !~ /$help_whitespace/ ) && ( $line !~ /^[\r\n]+/ ) ) {
+ if ( ( $line !~ /^$help_whitespace/ ) && ( $line !~ /^[\r\n]+/ ) ) {
$inside_help = 0;
$help_whitespace = "";
+ $help_keyword_whitespace = "";
}
else { #if it's not ended, add the line to the helptext array for the symbol's instance
if ($inside_config) {
@@ -1034,10 +1044,15 @@
if ($help_whitespace) { $line =~ s/^$help_whitespace//; }
push( @{ $symbols{$inside_config}{$sym_num}{helptext} }, $line );
}
+ if ( ($help_keyword_whitespace eq $help_whitespace) && ( $line !~ /^[\r\n]+/ ) ) {
+ show_error("$filename:$line_no - help text needs additional indentation.");
+ }
}
}
elsif ( ( $line =~ /^(\s*)help/ ) || ( $line =~ /^(\s*)---help---/ ) ) {
$inside_help = $line_no;
+ $line =~ /^(\s+)/;
+ $help_keyword_whitespace = $1;
if ( ( !$inside_config ) && ( !$inside_choice ) ) {
if ($show_note_output) {
print "# Note: $filename:$line_no help is not inside a config or choice block.\n";
diff --git a/util/lint/kconfig_lint_README b/util/lint/kconfig_lint_README
index 5bd2bdd..d20a933 100644
--- a/util/lint/kconfig_lint_README
+++ b/util/lint/kconfig_lint_README
@@ -45,7 +45,6 @@
Warnings in Kconfig files:
- Any 'default' expressions that can never be reached.
- Symbols that are defined but never used.
-- Help text starting with no whitespace.
- Directories specified in a 'source' keyword do not exist.
- A 'source' keyword loading a Kconfig file that has already been loaded.
- A 'source' keyword loading a Kconfig file that doesn't exist. Note that
@@ -78,6 +77,8 @@
- Lines not ending with a linefeed. These can cause some keywords to not
function properly ('source' keywords in particular). It's also just
generally good to end the file with a linefeed.
+- Help text starting with no whitespace.
+- Help text that starts at the same indentation level as the 'help' keyword.
Errors in Kconfig that are also caught by Kconfig itself:
- Invalid expressions.
--
To view, visit https://review.coreboot.org/19851
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf868c83e2a128ceb6c4d3da7f2cf7dc237054e6
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Martin Roth <martinroth at google.com>
More information about the coreboot-gerrit
mailing list