Skip to content

internal imports by default, only enable warnings as errors in CI#112

Merged
tayloraswift merged 1 commit intomasterfrom
internal-imports
Mar 14, 2026
Merged

internal imports by default, only enable warnings as errors in CI#112
tayloraswift merged 1 commit intomasterfrom
internal-imports

Conversation

@tayloraswift
Copy link
Owner

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 refactors the Swift package configuration to adopt the 'InternalImportsByDefault' feature, enhancing module encapsulation and preparing for future Swift language evolution. It also introduces conditional compilation for treating specific warnings as errors, enabling stricter checks in CI while providing flexibility for local development.

Highlights

  • Conditional Warnings as Errors: Warnings for 'ExistentialAny' and 'MutableGlobalVariable' are now only treated as errors when the WARNINGS_AS_ERRORS environment variable is explicitly set, allowing for more flexible local development while maintaining strictness in CI.
  • Enabled 'InternalImportsByDefault' Feature: The Swift package manifest has been updated to enable the upcoming 'InternalImportsByDefault' Swift feature, which changes the default visibility of imported modules to internal.
  • CI Build Configuration Update: The TestAll script now exports WARNINGS_AS_ERRORS=1 and includes --explicit-target-dependency-import-check=error for release builds, ensuring that strict warning and import checks are enforced in continuous integration environments.
  • Adjusted Import Visibility: Numerous import statements across JSONDecoding, JSONParsing, and JavaScriptPersistence modules have been explicitly marked as public import or internal import to align with the new InternalImportsByDefault feature and clarify module dependencies.
Changelog
  • Package.swift
    • Added conditional logic to treat specific warnings as errors based on an environment variable.
    • Enabled the 'InternalImportsByDefault' Swift feature.
    • Imported Foundation.ProcessInfo to read environment variables.
  • Scripts/TestAll
    • Configured the script to export WARNINGS_AS_ERRORS=1.
    • Added --explicit-target-dependency-import-check=error to the release build command.
    • Updated shell options to set -euo pipefail for increased robustness.
  • Sources/JSONDecoding/Decoding/JSON.DecodingError.swift
    • Changed import TraceableErrors to public import TraceableErrors.
  • Sources/JSONParsing/JSON.Array (ext).swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/JSON.Node (ext).swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/JSON.Object (ext).swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON (ext).swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.Array.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.False.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.Inf.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.NaN.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.Nonfinite.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.Null.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.Object.Item.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.Object.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.True.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NodeRule.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NumberRule.PlusOrMinus.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.NumberRule.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.RootRule.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.StringRule.CodeUnit.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.StringRule.EscapeSequence.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.StringRule.EscapedCodeUnit.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.StringRule.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JSONParsing/Rules/JSON.WhitespaceRule.swift
    • Changed import Grammar to internal import Grammar.
  • Sources/JavaScriptPersistence/JSObject.swift
    • Changed import JSON to public import JSON.
  • Sources/JavaScriptPersistence/JSValue.swift
    • Changed import JSON to public import JSON.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/Documentation.yml
    • .github/workflows/Tests.yml
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

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.

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 enables the InternalImportsByDefault Swift feature and configures warnings to be treated as errors only in CI environments. The changes correctly adjust import statements across various modules to be either internal or public as needed, and the CI script is updated to enable warnings as errors. My review includes one suggestion in Package.swift to simplify the logic for checking the environment variable, improving code readability.

Comment on lines +91 to +95
switch ProcessInfo.processInfo.environment["WARNINGS_AS_ERRORS"] {
case "true"?: true
case "1"?: true
default: false
}

Choose a reason for hiding this comment

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

medium

The logic for checking the WARNINGS_AS_ERRORS environment variable can be simplified for better readability and conciseness. Using a direct boolean comparison is more idiomatic and easier to understand than a switch statement on an optional value.

    let value = ProcessInfo.processInfo.environment["WARNINGS_AS_ERRORS"]
    return value == "true" || value == "1"

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

Successfully merging this pull request may close these issues.

1 participant