Skip to content

RedundantShell

Same shell is defined both on step and globally.

Defined by RedundantShellRule which supports workflows in the "Default" ruleset along with RedundantDefaultShell.

Description

Duplication can lead to confusion.

The shell: can be specified on 3 levels, and the lowest wins:

This means that when the workflow or job has the shell defined, the steps' definitions are not necessary.

Compliant example

Default shell is defined on job.

example.yml

on: push
jobs:
  example:
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
    steps:
      - run: echo "Example"

Non-compliant examples

Non-compliant example #1

Default shell is defined on job, but steps also repeat it.

example.yml

on: push
jobs:
  example:
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
    steps:
      - run: echo "Example"
        shell: bash

  • Line 9: Both Job[example] and Step[#0] in Job[example] has bash shell, the step's shell can be removed.

Non-compliant example #2

Default shell is defined on workflow, but steps also repeat it.

example.yml

on: push
defaults:
  run:
    shell: bash
jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Example"
        shell: bash

  • Line 9: Both Workflow[example] and Step[#0] in Job[example] has bash shell, the step's shell can be removed.