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

Shell error with rake task #346

Open
lloydwatkin opened this issue Jan 30, 2020 · 9 comments
Open

Shell error with rake task #346

lloydwatkin opened this issue Jan 30, 2020 · 9 comments

Comments

@lloydwatkin
Copy link
Contributor

!!! Running `rubycritic` rake command
!!! Inspecting app/errors app/jobs app/serializers app/tasks app/assets app/exceptions app/mailers app/services app/uploaders app/controllers app/helpers app/models app/states app/views with options --mode-ci --format json --no-browser
Warning: you are leaving 5 commits behind, not connected to
any of your branches:
  045b88d Merge d43ecf263cf6f45b7f1981e07cd489b9e7d23a52 into dec6daea97a124a57a5c599768e2fdca7ab99011
  d43ecf2 Fix up tests
  171d4a4 Update list of what is being observed
  ebbc596 Missed the addition of the observer
  a5353a5 Move mixpanel/mailchimp updates to on-demand observer setup
If you want to keep them by creating a new branch, this may be a good time
to do so with:
 git branch <new-branch-name> 045b88d
Switched to branch 'master'
running flay smells
.................................................
running flog smells
........................................................................................................................................................................................................................................................................................................................................................................................
running reek smells
........................................................................................................................................................................................................................................................................................................................................................................................
running complexity
........................................................................................................................................................................................................................................................................................................................................................................................
running attributes
........................................................................................................................................................................................................................................................................................................................................................................................
running churn
........................................................................................................................................................................................................................................................................................................................................................................................
running simple_cov
........................................................................................................................................................................................................................................................................................................................................................................................
sh: 1: Syntax error: "(" unexpected
running flay smells
.................................................
running flog smells
........................................................................................................................................................................................................................................................................................................................................................................................
running reek smells
........................................................................................................................................................................................................................................................................................................................................................................................
running complexity
........................................................................................................................................................................................................................................................................................................................................................................................
running attributes
........................................................................................................................................................................................................................................................................................................................................................................................
running churn
........................................................................................................................................................................................................................................................................................................................................................................................
running simple_cov
........................................................................................................................................................................................................................................................................................................................................................................................
sh: 1: Syntax error: "(" unexpected
Score (87.54) is below the minimum 95
The command "bundle exec rspec && bundle leak check --update && bundle audit check --update && git reset --hard && bundle exec rake rubycritic" exited with 0.
@etagwerker
Copy link
Collaborator

@lloydwatkin Weird. What version of rubycritic are you using?

@lloydwatkin
Copy link
Contributor Author

Latest 2.4.3

@etagwerker
Copy link
Collaborator

@lloydwatkin Could you share your Gemfile.lock and .rubycritic.yml? I can't reproduce this issue without more information.

@lloydwatkin
Copy link
Contributor Author

# frozen_string_literal: true
if defined?(Rails) && (Rails.env.development? || Rails.env.test?)
  require "rubycritic/rake_task"

  RubyCritic::RakeTask.new do |task|
    task.name = 'rubycritic'
    task.options = '--mode-ci --format json --no-browser'
    task.verbose = true
    task.paths   = FileList[
      'app/errors',
      'app/jobs',
      'app/serializers',
      'app/tasks',
      'app/assets',
      'app/exceptions',
      'app/mailers',
      'app/services',
      'app/uploaders',
      'app/controllers',
      'app/helpers',
      'app/models',
      'app/states',
      'app/views',
    ]
  end
end

@chrishough
Copy link

I am getting the same error, latest version, and I am using the command line.
bundle exec rubycritic --no-browser --mode-ci --minimum-score=95

@chrishough
Copy link

UPDATE

I tested this a number of ways, and it is only occurring on my github actions CI setup when I include the --mode-ci flag.

It does not occur with this setup below.

name: Build and Test Application

on:
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:12
        ports:
          - 5432:5432
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - uses: actions/checkout@v1

      # ----------------------------------------------------Postgres

      - name: Install Postgres Dependencies
        run: sudo apt-get install libpq-dev

      # ----------------------------------------------------Ruby

      - name: Install Ruby
        uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.7.x

      - name: Ruby Version
        run: |
          ruby -v

      - name: Setup Ruby Dependencies
        run: |
          gem update bundler
          bundle install --jobs 4 --retry 3

      # ----------------------------------------------------Postgres

      - name: Setup Database
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          RAILS_ENV: continuous_integration
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          export RUBYOPT='-W:no-deprecated -W:no-experimental'
          echo 'Running: bundle exec rake db:create db:structure:load'
          bundle exec rake db:create db:structure:load

      # ----------------------------------------------------Rubocop

      - name: Rubocop Quality Checks
        run: |
          echo 'Running: bundle exec rubocop'
          bundle exec rubocop

      # ----------------------------------------------------Brakeman

      - name: Brakeman Quality Checks
        run: |
          echo 'Running: bundle exec brakeman'
          bundle exec brakeman

      # ----------------------------------------------------RubyCritic

      - name: RubyCritic Quality Checks
        run: |
          export RUBYOPT='-W:no-deprecated -W:no-experimental'
          echo 'Running: bundle exec rubycritic --no-browser --minimum-score=95'
          bundle exec rubycritic --no-browser --minimum-score=95

      # ----------------------------------------------------Rspec

      - name: Rspec Automated Tests
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          RAILS_ENV: continuous_integration
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          export RUBYOPT='-W:no-deprecated -W:no-experimental'
          echo 'Running: bundle exec rspec --format=documentation'
          bundle exec rspec --format=documentation

@jd-erreape
Copy link

Hi! I'm having exactly the same issue trying to run the ci mode en a gitlab CI runner.

I've realised (it seems) that when the error appears, the switch from master to the current branch to compare doesn't occur, this can also be seen in the first comment of this issue (the log line saying 'Switched to branch ...' is not there).

Note that I'm not even using bundler or the project Gemfile to run rubycritic (just to speed up the pipeline), just checking out the code and installing rubycritic alone, all other modes look ok, just having issues on this specific case using ci mode.

@h-r-k-matsumoto
Copy link
Contributor

I faced the same issue with GitHub Actions.
It's a problem that is happened if nothing is a branch.

When using the following code,

      - name: Rubycritic
        run: |
          git branch
          gem install rubycritic
          rubycritic

git branch command outputs * (HEAD detached at pull/69/merge) .
The error happen in this situation.

I resolved it just to check out an appropriate branch.

      - name: Rubycritic
        run: |
          git checkout -b ${{ github.head_ref}} # need check out
          gem install rubycritic
          rubycritic

h-r-k-matsumoto added a commit to h-r-k-matsumoto/rubycritic that referenced this issue Jan 11, 2023
Fix issue whitesmith#346

This commit prevents `sh: 1: Syntax error: "(" unexpected` error and completes the run with compare mode successfully.
etagwerker added a commit that referenced this issue Apr 29, 2023
Fix issue #346

This commit prevents `sh: 1: Syntax error: "(" unexpected` error and completes the run with compare mode successfully.

Co-authored-by: Ernesto Tagwerker <[email protected]>
@rishijain
Copy link
Contributor

Hey, I think this was fixed in #424 and can be closed.

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

6 participants