Yamllint reports missing ':'--Why?

Viewed 284

I borrowed some code that contained googletest code for c++ code. At this point, however, I am interested in everything, so when my Yamllint tool started reporting errors, I paid attention. I want to understand the code that we are learning to use. This example was done on github, in a workflow in the appveyor.yml. Yamllint is reporting the following

57:5 error syntax error: could not find expected ':' (syntax)

This isn't very helpful, but as far as I can see the syntax is correct. At first I thought the branch syntax was missing something, but I couldn't find any problem. I separated the else as a second if branch wihtout the not. The error still persisted on the same line. It may be a bug in yamllint itself, but I can't conclude that because I'm not terribly familiar with yaml syntax. I may be missing someting.

install:
  - ps: |
    Write-Output "Compiler: $env:compiler"
    Write-Output "Generator: $env:generator"
    Write-Output "Env:Configuation: $env:configuration"
    Write-Output "Env: $env"
    if (-not (Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER)) {
      Write-Output "This is *NOT* a pull request build"
    }  <-- REPORTED MISSING ':'
    else
    {
      Write-Output "This is a pull request build"
      if (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes") {
        Write-Output "PR builds are *NOT* explicitly enabled"
      }
    }

So, bottom line is, what is provoking this error? If the problem is with my code, I'd appreciate someone indicating what the correct syntax is. If the problem is in yamllint, I'd like to report the bug.

1 Answers

You have an error in your indentation. Indent everything after - ps: | one more time and it will be parsed without errors:

install:
  - ps: |
      Write-Output "Compiler: $env:compiler"
      Write-Output "Generator: $env:generator"
      Write-Output "Env:Configuation: $env:configuration"
      Write-Output "Env: $env"
      if (-not (Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER)) {
        Write-Output "This is *NOT* a pull request build"
      }  
      else
      {
        Write-Output "This is a pull request build"
        if (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes") {
          Write-Output "PR builds are *NOT* explicitly enabled"
        }
      }
Related