Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of hashes one-liner throws a "Indentation of => is not properly aligned" #446

Closed
LinguineCode opened this issue Sep 20, 2015 · 1 comment

Comments

@LinguineCode
Copy link

The rewrites param below looks complicated, but it's just a $variable being concatenated with one array of hashes. When writing it this way puppet-lint will throw a Indentation of => is not properly aligned. I use one-liners a lot and and puppet-lint usually lets me do it. This time I wasn't so lucky.

      apache::vhost { "ssl-${servername}":
        port              => $ssl_port,
        servername        => $servername,
        docroot           => $docroot,
        access_log_file   => $access_log_file,
        error_log_file    => $error_log_file,
        access_log_format => $access_log_format,
        rewrites          => concat($rewrites,[ { rewrite_cond => '%{HTTPS} !=on', rewrite_rule => '^/?(.*) https://%{SERVER_NAME}/$1 [R,L]', }, ]),
        override          => $override,
        proxy_pass        => $proxy_pass,
        serveraliases     => $serveraliases,
        directories       => $directories,
        ssl               => true,
        ssl_cert          => $actual_ssl_cert,
        ssl_key           => $actual_ssl_key,
        ssl_chain         => $actual_ssl_chain,
      }

I was curious what --fix thinks it should be. It splits it into 2 lines like so:

        rewrites          => concat($rewrites,[ { rewrite_cond        => '%{HTTPS} !=on',
 rewrite_rule        => '^/?(.*) https://%{SERVER_NAME}/$1 [R,L]', }, ]),

OK, that's not so bad. If that is what it takes to make puppet-lint happy, I'll settle for it.

Another workaround is to put the data into a variable first

  $another_rewrite = [ { rewrite_cond => '%{HTTPS} !=on', rewrite_rule => '^/?(.*) https://%{SERVER_NAME}/$1 [R,L]', }, ]

      apache::vhost { "ssl-${servername}":
        port              => $ssl_port,
        servername        => $servername,
        docroot           => $docroot,
        access_log_file   => $access_log_file,
        error_log_file    => $error_log_file,
        access_log_format => $access_log_format,
        rewrites          => concat($rewrites,$another_rewrite),
        override          => $override,
        proxy_pass        => $proxy_pass,
        serveraliases     => $serveraliases,
        directories       => $directories,
        ssl               => true,
        ssl_cert          => $actual_ssl_cert,
        ssl_key           => $actual_ssl_key,
        ssl_chain         => $actual_ssl_chain,
      }
@rnelson0
Copy link
Collaborator

Some recent changes in alignment code have fixed this:

$ cat 446.pp
#
class fourfoursix {
      apache::vhost { "ssl-${servername}":
        port              => $ssl_port,
        servername        => $servername,
        docroot           => $docroot,
        access_log_file   => $access_log_file,
        error_log_file    => $error_log_file,
        access_log_format => $access_log_format,
        rewrites          => concat($rewrites,[ { rewrite_cond => '%{HTTPS} !=on', rewrite_rule => '^/?(.*) https://%{SERVER_NAME}/$1 [R,L]', }, ]),
        override          => $override,
        proxy_pass        => $proxy_pass,
        serveraliases     => $serveraliases,
        directories       => $directories,
        ssl               => true,
        ssl_cert          => $actual_ssl_cert,
        ssl_key           => $actual_ssl_key,
        ssl_chain         => $actual_ssl_chain,
      }
}
$ be puppet-lint 446.pp --fix
ERROR: fourfoursix not in autoload module layout on line 2
WARNING: top-scope variable being used without an explicit namespace on line 4
WARNING: top-scope variable being used without an explicit namespace on line 6
WARNING: top-scope variable being used without an explicit namespace on line 7
WARNING: top-scope variable being used without an explicit namespace on line 8
WARNING: top-scope variable being used without an explicit namespace on line 9
WARNING: top-scope variable being used without an explicit namespace on line 10
WARNING: top-scope variable being used without an explicit namespace on line 11
WARNING: top-scope variable being used without an explicit namespace on line 12
WARNING: top-scope variable being used without an explicit namespace on line 13
WARNING: top-scope variable being used without an explicit namespace on line 14
WARNING: top-scope variable being used without an explicit namespace on line 16
WARNING: top-scope variable being used without an explicit namespace on line 17
WARNING: top-scope variable being used without an explicit namespace on line 18
FIXED: indentation of => is not properly aligned (expected in column 64, but found it in column 97) on line 10
$ cat 446.pp
#
class fourfoursix {
      apache::vhost { "ssl-${servername}":
        port              => $ssl_port,
        servername        => $servername,
        docroot           => $docroot,
        access_log_file   => $access_log_file,
        error_log_file    => $error_log_file,
        access_log_format => $access_log_format,
        rewrites          => concat($rewrites,[ { rewrite_cond => '%{HTTPS} !=on',
                                                  rewrite_rule => '^/?(.*) https://%{SERVER_NAME}/$1 [R,L]', }, ]),
        override          => $override,
        proxy_pass        => $proxy_pass,
        serveraliases     => $serveraliases,
        directories       => $directories,
        ssl               => true,
        ssl_cert          => $actual_ssl_cert,
        ssl_key           => $actual_ssl_key,
        ssl_chain         => $actual_ssl_chain,
      }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants