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

Add update_activity errors to aggregated errors for mailing #5958

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
end

act.save
rescue ConfigParseError => e
# add error to the list of errors
errors.push e

Check warning on line 279 in app/models/repository.rb

View check run for this annotation

Codecov / codecov/patch

app/models/repository.rb#L279

Added line #L279 was not covered by tests
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Initialize the errors array before using it

The errors array is being used but not initialized in the method scope. This could lead to undefined method 'push' for nil:NilClass errors.

Apply this diff to fix the issue:

  def update_activity(act)
+   errors = []
    config = act.merged_config
    # ... rest of the method ...
  rescue ConfigParseError => e
    # add error to the list of errors
    errors.push e
  end

Additionally, consider passing the errors array as a parameter to make error collection more explicit:

- def update_activity(act)
+ def update_activity(act, errors = [])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rescue ConfigParseError => e
# add error to the list of errors
errors.push e
def update_activity(act, errors = [])
rescue ConfigParseError => e
# add error to the list of errors
errors.push e
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 279-279: app/models/repository.rb#L279
Added line #L279 was not covered by tests

end

def github_url(path = nil, mode: nil)
Expand Down