Skip to content

Commit

Permalink
Refactor Java Identifier and error handling for metadata determination
Browse files Browse the repository at this point in the history
  • Loading branch information
tamannaaaaa committed Aug 3, 2023
1 parent 62f09e5 commit c591f75
Showing 1 changed file with 22 additions and 3 deletions.
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 @@ func (i *identify) PlanType() types.PlanType {
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

0 comments on commit c591f75

Please sign in to comment.