Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class BugReportGenerator

private static final String ECLIPSE_LOG_FILE_NAME = ".log"; //$NON-NLS-1$
private static final String ECLIPSE_METADATA_DIRECTORY = ".metadata"; //$NON-NLS-1$
private static final String IDE_LOG_REPORT_NAME_PREFIX = "ide_error_log"; //$NON-NLS-1$
private static final String UNKNOWN = "Unknown"; //$NON-NLS-1$
private static final String BUG_REPORT_DIRECTORY_PREFIX = "bug_report_"; //$NON-NLS-1$
private File bugReportDirectory;
Expand Down Expand Up @@ -189,6 +190,16 @@ private List<File> getIdeMetadataLogsFile()
return logFiles;
}

// Eclipse stores the IDE error log as ".log" (hidden on macOS/Linux); rename so it stays visible in the report.
public static String getReportLogFileName(String metadataFileName)
{
if (metadataFileName.startsWith(".")) //$NON-NLS-1$
{
return IDE_LOG_REPORT_NAME_PREFIX + metadataFileName;
}
return metadataFileName;
Comment on lines +194 to +200

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the destination-conflict behavior of FileUtil.copyFile.
fd 'FileUtil.java' . -x sh -c '
  echo "=== $1 ==="
  rg -n -C 8 "\bcopyFile\s*\(" "$1"
' sh {}

# Find existing tests and filename-copy call sites.
rg -n -C 5 'getReportLogFileName|copyFile\(|ide_error_log\.log' \
  bundles tests

Repository: espressif/idf-eclipse-plugin

Length of output: 10041


Prevent report filename collisions.

.log is renamed to ide_error_log.log, but a visible ide_error_log.log uses the same destination path. Use a unique report name when the destination already exists. Add a test that copies both source files into one report.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java`
around lines 194 - 200, Update getReportLogFileName to ensure the generated
report filename is unique when the destination already exists, including
collisions between the renamed hidden .log file and an existing visible
ide_error_log.log. Preserve the current naming behavior when no collision
occurs, and add a test covering both source files being copied into a single
report.

}

private File createBasicSystemInfoFile() throws IOException
{
String osName = System.getProperty("os.name", UNKNOWN); //$NON-NLS-1$
Expand Down Expand Up @@ -282,7 +293,8 @@ public String generateBugReport()

for (File logFile : metadataLogsFile)
{
FileUtil.copyFile(logFile, new File(ideLogDir.getAbsolutePath() + File.separator + logFile.getName()));
FileUtil.copyFile(logFile, new File(
ideLogDir.getAbsolutePath() + File.separator + getReportLogFileName(logFile.getName())));
}
File eimLogPath = getEimLogPath();
Logger.log("EIM log path: " + eimLogPath.getAbsolutePath()); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright 2026 Espressif Systems (Shanghai) PTE LTD.
* All rights reserved. Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.core.bug.test;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import com.espressif.idf.core.bug.BugReportGenerator;

@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
public class BugReportGeneratorTest
{

@ParameterizedTest(name = "''{0}'' is collected as ''{1}''")
@CsvSource({ ".log, ide_error_log.log", ".bak_0.log, ide_error_log.bak_0.log",
".bak_1.log, ide_error_log.bak_1.log" })
void test_hidden_ide_log_gets_a_visible_name(String metadataFileName, String expectedReportFileName)
{
String reportFileName = BugReportGenerator.getReportLogFileName(metadataFileName);

Assertions.assertEquals(expectedReportFileName, reportFileName);
}

@ParameterizedTest(name = "''{0}'' is collected unchanged")
@CsvSource({ "version.ini", "workspace.log" })
void test_already_visible_file_name_is_kept(String metadataFileName)
{
String reportFileName = BugReportGenerator.getReportLogFileName(metadataFileName);

Assertions.assertEquals(metadataFileName, reportFileName);
}

@Test
void test_no_collected_file_stays_hidden()
{
Assertions.assertFalse(BugReportGenerator.getReportLogFileName(".log").startsWith("."));
}
}
Loading