-
Notifications
You must be signed in to change notification settings - Fork 1
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
Experimental API for malysis integration #14
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Omkar Phansopkar <[email protected]>
fs/filesystem.go
Outdated
@@ -33,6 +43,31 @@ func (f *localFile) IsImport() bool { | |||
return f.isImport | |||
} | |||
|
|||
func NewReaderFile(reader io.Reader, path string, isImport bool) *readerFile { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func NewReaderFile(reader io.Reader, path string, isImport bool) *readerFile { | |
func NewFileFromReader(reader io.Reader, path string, isImport bool) *readerFile { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a documentation for this function since it is exported.
lang/factory.go
Outdated
@@ -22,3 +24,19 @@ func GetLanguage(name string) (core.Language, error) { | |||
|
|||
return nil, fmt.Errorf("language not found: %s", name) | |||
} | |||
|
|||
func ResolveLanguage(filePath string) (core.Language, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a documentation for this function since it is exported.
lang/factory.go
Outdated
@@ -22,3 +24,19 @@ func GetLanguage(name string) (core.Language, error) { | |||
|
|||
return nil, fmt.Errorf("language not found: %s", name) | |||
} | |||
|
|||
func ResolveLanguage(filePath string) (core.Language, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func ResolveLanguage(filePath string) (core.Language, error) { | |
func ResolveLanguageFromPath(filePath string) (core.Language, error) { |
Since this is an exported function and package global (i.e. not within a struct receiver), I think we should name it as explicitly as possible.
@OmkarPh The |
lang/factory.go
Outdated
@@ -22,3 +24,19 @@ func GetLanguage(name string) (core.Language, error) { | |||
|
|||
return nil, fmt.Errorf("language not found: %s", name) | |||
} | |||
|
|||
func ResolveLanguage(filePath string) (core.Language, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test for this.
Signed-off-by: Omkar Phansopkar <[email protected]>
updated naming and docs |
@OmkarPh Is this ready for review? I see this is still in draft status |
Primarily, I've introduced another
core.File
implementation -readerFile
(can be renamed to "artifactFile" / "standaloneFile" / any suggestions ?)This allows using
ArtifactFile
to be used with already available plugin APIsThis can be used in malysis in place of static.go#L201 like -
Maybe, we can also have a util function for reusability, created at malysis level, which accepts an artifactFile and returns a
io.Reader
(reader fromStripCommentsPluginData
or the default one in case of unsupported lang)