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

Refactor Java Identifier and error handling for metadata determination #118

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 22 additions & 3 deletions internal/java/identify.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,38 @@
return types.PlanTypeJava
}

// Match checks if the given filesystem contains files specific to Java projects.
func (i *identify) Match(fs afero.Fs) bool {
return utils.HasFile(
fs, "pom.xml", "pom.yml", "pom.yaml", "build.gradle",
"build.gradle.kts",
)
}

// PlanMeta returns metadata about the identified Java project.
func (i *identify) PlanMeta(options plan.NewPlannerOptions) types.PlanMeta {
projectType := DetermineProjectType(options.Source)
framework := DetermineFramework(projectType, options.Source)
jdkVersion := DetermineJDKVersion(projectType, options.Source)
// Determine the project type
projectType, err := DetermineProjectType(options.Source)

Check failure on line 33 in internal/java/identify.go

View workflow job for this annotation

GitHub Actions / test

assignment mismatch: 2 variables but DetermineProjectType returns 1 value
if err != nil {
projectType = "unknown" // Handle error gracefully, set default value
}

// Determine the framework
framework, err := DetermineFramework(projectType, options.Source)

Check failure on line 39 in internal/java/identify.go

View workflow job for this annotation

GitHub Actions / test

assignment mismatch: 2 variables but DetermineFramework returns 1 value
if err != nil {
framework = "unknown" // Handle error gracefully, set default value
}

// Determine JDK version
jdkVersion, err := DetermineJDKVersion(projectType, options.Source)

Check failure on line 45 in internal/java/identify.go

View workflow job for this annotation

GitHub Actions / test

assignment mismatch: 2 variables but DetermineJDKVersion returns 1 value
if err != nil {
jdkVersion = "unknown" // Handle error gracefully, set default value
}

// Determine target extension
targetExt := DetermineTargetExt(options.Source)

// Create and return the PlanMeta
return types.PlanMeta{
"type": string(projectType),
"framework": string(framework),
Expand Down
Loading