Skip to content

Fix slice warning from logs#57

Merged
samhamilton merged 1 commit intomainfrom
FIX-SLICE-WARNING
Jun 30, 2025
Merged

Fix slice warning from logs#57
samhamilton merged 1 commit intomainfrom
FIX-SLICE-WARNING

Conversation

@dgross881
Copy link
Contributor

This PR fixes the warning

(elixir 1.18.4) lib/string.ex:2427: String.slice/2
warning: negative steps are not supported in String.slice/2, pass 0..-2//1 instead

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @dgross881, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a specific warning related to the String.slice/2 function in Elixir, ensuring compatibility with newer Elixir versions and preventing unnecessary log output. The change updates the range specification for string slicing to use a positive step value as recommended by the warning.

Highlights

  • Warning Fix: Addressed a String.slice/2 warning in Elixir 1.18.4 by updating the step value in the slice range from -1 to 1.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@samhamilton samhamilton changed the title fix(WEB-0): Fix slice warning from logs Fix slice warning from logs Jun 30, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly resolves a deprecation warning related to String.slice/2 by updating the String.slice call to use the correct divisor. A suggestion was made to use String.slice/3 for better readability.


if String.ends_with?(path, "/") && path != "/" do
new_path = String.slice(path, 0..-2//-1)
new_path = String.slice(path, 0..-2//1)

Choose a reason for hiding this comment

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

medium

Consider using String.slice/3 for better readability. The expression String.slice(path, 0, -1) is a common Elixir idiom for getting a string without its last character. It's often considered more direct and easier to understand at a glance than the range 0..-2. This would make the intent of the code even clearer.

      new_path = String.slice(path, 0, -1)

@samhamilton samhamilton merged commit 2d1f17c into main Jun 30, 2025
15 checks passed
@samhamilton samhamilton deleted the FIX-SLICE-WARNING branch June 30, 2025 08:23
@samhamilton samhamilton added enhancement New feature or request elixir Pull requests that update Elixir code labels Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

elixir Pull requests that update Elixir code enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants