Code Quality Job Yaml Error

code_quality:
  stage: code_analysis
  image: docker:latest
  variables:
    CODE_QUALITY_IMAGE: registry.gitlab.com/gitlab-org/ci-cd/codequality:latest
  before_script:
    - echo $CODE_QUALITY_IMAGE
  tags:
   - linux
  retry:
    max: 2
    when: runner_system_failure
  rules:
    - if: '$CODE_QUALITY_DISABLED'
      when: never
    - if: '$CI_COMMIT_BRANCH =~ /^([f]eature)\/.+$/'

Do rules work with code quality?
Is this the correct way to define rules within the job definition?