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
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
plugin/js/detectRunTime/node_modules/

plugin/js/getDependencies/node_modules/

plugin/js/preDetectCommands/node_modules/

.idea/

plugin/globalDetectors/commands/plugin
Expand All @@ -24,4 +18,3 @@ plugin/go/staticAssets/plugin
plugin/go/testCasesCommands/plugin
cover/
cover/coverage.out
detect-runtime
3 changes: 3 additions & 0 deletions GlobalFiles/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import (
"code-analyser/protos/pb/output/globalFiles"
)

//ProcFile plugin methods
type ProcFile interface {
Detect(path *helpers.StringInput) (*globalFiles.ProcFile, error)
}

//Makefile plugin methods
type Makefile interface {
Detect(path *helpers.StringInput) (*globalFiles.MakeFile, error)
}

//DockerFile plugin methods
type DockerFile interface {
DetectDockerFile(path *helpers.StringInput) (*globalFiles.DockerFile, error)
DetectDockerComposeFile(path *helpers.StringInput) (*globalFiles.DockerCompose, error)
Expand Down
1 change: 1 addition & 0 deletions detectLanguage/analyse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type File struct {
Name string
Percent float64
}

//must be correct path of enry binary
var enryLoc = "./static/"

Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ go 1.16
require (
github.com/Masterminds/semver v1.5.0
github.com/chrismytton/procfile v1.0.0
github.com/fatih/color v1.10.0 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/go-cmd/cmd v1.3.0
github.com/hashicorp/go-hclog v0.14.1
github.com/hashicorp/go-plugin v1.4.0
github.com/mgechev/revive v1.0.9 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.uber.org/atomic v1.8.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.18.1
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/tools v0.1.4 // indirect
google.golang.org/genproto v0.0.0-20210406143921-e86de6bf7a46 // indirect
google.golang.org/grpc v1.37.0
google.golang.org/protobuf v1.26.0
Expand Down
29 changes: 25 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af h1:spmv8nSH9h5oCQf40jt/ufBCt9j0/58u4G+rkeMqXGI=
github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af/go.mod h1:Qjyv4H3//PWVzTeCezG2b9IRn6myJxJSr4TD/xo6ojU=
github.com/chrismytton/procfile v1.0.0 h1:H1qBpcGKG/za57TOB1EHMvTeT/2oH7K0T89rsKWvFSg=
github.com/chrismytton/procfile v1.0.0/go.mod h1:Xf4ziDMgX08pZLjsRwiWh/J6Nd73UZVTUSUkO+nDq+Q=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand All @@ -18,8 +21,10 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/go-cmd/cmd v1.3.0 h1:Wet2eYkLouFqyiG+x6P6l8CICRywhRD6sjMNalTSvbs=
github.com/go-cmd/cmd v1.3.0/go.mod h1:l/X/csRuYRDqiQIz9PPJBn4xDrdxgBXeLE9x1BeFU6M=
github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
Expand Down Expand Up @@ -68,13 +73,24 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81 h1:QASJXOGm2RZ5Ardbc86qNFvby9AqkLDibfChMtAg5QM=
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg=
github.com/mgechev/revive v1.0.9 h1:gEtqczoFbIfi6tMaYGbrvU6liYjIDNwWL5aDxvHWtJM=
github.com/mgechev/revive v1.0.9/go.mod h1:D5z6BNQBucjRhTYPoNU33S2bEFGR6aFUrJyV83ZQS/I=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand All @@ -86,6 +102,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.8.0 h1:CUhrE4N1rqSE6FM9ecihEjRkLQu8cDfgDyoOs83mEY4=
go.uber.org/atomic v1.8.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
Expand All @@ -108,6 +125,7 @@ golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -124,6 +142,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -137,6 +156,7 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand All @@ -153,8 +173,9 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.4 h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
10 changes: 5 additions & 5 deletions helpers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
)

//SemverValidate takes semver and value to be matched
func SemverValidate(semverstring, value string) bool {
func SemverValidate(semverString, value string) bool {
if strings.Contains(value, "^") {
value = strings.Replace(value, "^", "", 1)
}
if strings.Contains(value, "~") {
value = strings.Replace(value, "~", "", 1)
}
c, err := semver.NewConstraint(semverstring)
c, err := semver.NewConstraint(semverString)
if err != nil {
utils.Logger(err, semverstring)
utils.Logger(err, semverString)
return false
}

Expand All @@ -32,8 +32,8 @@ func SemverValidate(semverstring, value string) bool {
}

//SemverValidateFromArray validates semver array and version
func SemverValidateFromArray(semverstrings []string, value string) bool {
for _, sem := range semverstrings {
func SemverValidateFromArray(semverString []string, value string) bool {
for _, sem := range semverString {
if SemverValidate(sem, value) {
return true
}
Expand Down
10 changes: 0 additions & 10 deletions languageDetectors/detector.go

This file was deleted.

1 change: 1 addition & 0 deletions languageDetectors/interfaces/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package interfaces
import "code-analyser/protos/pb/helpers"
import "code-analyser/protos/pb/output/languageSpecific"

//Commands plugin methods
type Commands interface {
DetectBuildCommands(path *helpers.StringInput) (*languageSpecific.CommandOutput, error)
DetectStartUpCommands(path *helpers.StringInput) (*languageSpecific.CommandOutput, error)
Expand Down
2 changes: 1 addition & 1 deletion languageDetectors/interfaces/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"code-analyser/protos/pb/plugin"
)

//Db It contains methods for Db details
//Db plugin methods
type Db interface {
Detect(input *helpers.Input) (*plugin.BoolIntOutput, error) // deep level detection
IsUsed(input *helpers.Input) (*helpers.BoolOutput, error)
Expand Down
2 changes: 1 addition & 1 deletion languageDetectors/interfaces/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"code-analyser/protos/pb/output/languageSpecific"
)

// Env will be implemented for plugin
//Env plugin methods
type Env interface {
Detect(input *helpers.Input) (*languageSpecific.Envs, error)
}
2 changes: 1 addition & 1 deletion languageDetectors/interfaces/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"code-analyser/protos/pb/helpers"
)

//Framework It defines methods of framework
//Framework plugin methods
type Framework interface {
Detect(input *helpers.Input) (*helpers.BoolOutput, error) //todo: can return FrameworkOutput ?
IsUsed(input *helpers.Input) (*helpers.BoolOutput, error)
Expand Down
37 changes: 6 additions & 31 deletions languageDetectors/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,36 @@ package interfaces
import (
"code-analyser/protos/pb/helpers"
languageSpecificPB "code-analyser/protos/pb/output/languageSpecific"
"context"
)

//LanguageSpecificDetector It contains methods for detection of different dependencies
type LanguageSpecificDetector interface {
//DetectRuntime will give runtime version of the language
DetectRuntime(context.Context, string) (string, error)
//RunPreDetect will run to modify libraries and format code
RunPreDetect(context.Context, string, string) (bool, error)
// TODO: interface ?
RunParsers(context.Context, string, string) (interface{}, error)
// ParseENVs will return ENVs
// ParseENVs(context.Context, string) ([]*languageSpecificPB.EnvOutput, error)
////DetectFrameworks will return framework detected in Dir
DetectFrameworks(ctx context.Context, runtimeVersion string, root string) ([]*languageSpecificPB.FrameworkOutput, error)
//DetectDBs will return Dbs detected in string
DetectDBs(ctx context.Context, runtimeVersion, root string) (*languageSpecificPB.DBOutput, error)
//DetectORMs will return orm detected in string
DetectORMs(ctx context.Context, runtimeVersion, root string) (*languageSpecificPB.OrmOutput, error)
//DetectDependencies will return getDependencies detected in string
DetectDependencies(context.Context, string, string) ([]*languageSpecificPB.DependenciesOutput, error)
//DetectLibraries will return libraries detected in string
DetectLibraries(context.Context, string, string) ([]*languageSpecificPB.LibraryOutput, error)
//GetStaticAssets will return type of staticAssets detected in string
GetStaticAssets(context.Context, string, string) ([]*languageSpecificPB.StaticAssetsOutput, error)
GetStack(context.Context, string, string) ([]*languageSpecificPB.StackOutput, error)
DetectAppserver(context.Context, string, string) ([]*languageSpecificPB.AppserverOutput, error)
DetectBuildDirectory(context.Context, string, string) (*languageSpecificPB.BuildDirectoryOutput, error)
DetectTestCasesRunCommands(context.Context, string, string) ([]*languageSpecificPB.BuildDirectoryOutput, error) // Todo: proto
}

//TODO need to segregate and decouple our code

//DetectRunTime This is for DetectDockerFile version and its language
//DetectRunTime plugin methods
type DetectRunTime interface {
Detect(inputString *helpers.StringInput) (*helpers.StringOutput, error)
}

//Dependencies It is for all dependencies for example beego,gin,postgres
//Dependencies plugin methods
type Dependencies interface {
GetDependencies(inputString *helpers.Input) (*helpers.StringMapOutput, error)
}

//PreDetectCommands plugin methods
type PreDetectCommands interface {
RunPreDetect(input *helpers.Input) (*helpers.EmptyOutput, error)
}

//StaticAssets plugin methods
type StaticAssets interface {
Detect(input *helpers.Input) (*languageSpecificPB.StaticAssetsOutput, error)
}

//BuildDirectory plugin methods
type BuildDirectory interface {
Detect(input *helpers.Input) (*languageSpecificPB.BuildDirectoryOutput, error)
}

//TestCasesRunCommands plugin methods
type TestCasesRunCommands interface {
Detect(input *helpers.Input) (*languageSpecificPB.TestCasesCommand, error)
}
1 change: 1 addition & 0 deletions languageDetectors/interfaces/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"code-analyser/protos/pb/plugin"
)

//Library plugin methods
type Library interface {
Detect(input *helpers.Input) (*plugin.LibraryType, error) //todo:
IsUsed(*helpers.Input) (*helpers.BoolOutput, error)
Expand Down
2 changes: 1 addition & 1 deletion languageDetectors/interfaces/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"code-analyser/protos/pb/plugin"
)

//Orm It contains methods to get details of ORM
//Orm plugin methods
type Orm interface {
Detect(input *helpers.Input) (*plugin.OrmOutput, error) // deep level detection
IsUsed(input *helpers.Input) (*helpers.BoolOutput, error)
Expand Down
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"log"
)

//Analyser instantiation to call scrape function
type Analyser struct {
Setting *utils.Setting
}

func main() {
var ctx context.Context
var path = utils.RootDirPath()+"/testingRepos/languageSpecific/covid19india-react-master"
var path = utils.RootDirPath() + "/testingRepos/languageSpecific/covid19india-react-master"
logger, _ := zap.NewProduction()
set := utils.Setting{
Logger: logger,
Expand All @@ -32,8 +33,13 @@ func main() {
func (analyser *Analyser) Scrape(ctx context.Context, path string) (*decisionmakerPB.DecisionMakerInput, error) {
analyser.Setting.Logger.Debug("scrapping started")

analyser.Setting.Logger.Info("fetching languages and percent of usage of that language")
languages, _, _ := detectlanguage.GetLanguagesWithPercent(path)
analyser.Setting.Logger.Info("fetched languages and percentage successfully")

analyser.Setting.Logger.Info("fetching language list supported by us")
supportedLanguages, _ := SupportedLanguagesParser()
analyser.Setting.Logger.Info("language list fetched successfully")

decisionMakerInput := &decisionmakerPB.DecisionMakerInput{
LanguageSpecificDetections: []*decisionmakerPB.LanguageSpecificDetections{},
Expand All @@ -59,13 +65,15 @@ func (analyser *Analyser) Scrape(ctx context.Context, path string) (*decisionmak
analyser.Setting.Logger.Info("language plugin execution started")
for _, language := range languages {
if languagePlugin, ok := languagePlugins[language.Name]; ok {

analyser.Setting.Logger.Info(language.Name + " plugins execution started")
detections, err := languagePlugin.Run(ctx, path)
if err != nil {
return decisionMakerInput, err
}
decisionMakerInput.LanguageSpecificDetections = append(decisionMakerInput.LanguageSpecificDetections, detections)
analyser.Setting.Logger.Info(language.Name + " plugins execution completed")

}
}
analyser.Setting.Logger.Info("language plugin execution completed")
Expand All @@ -74,6 +82,7 @@ func (analyser *Analyser) Scrape(ctx context.Context, path string) (*decisionmak
return decisionMakerInput, nil
}

//LoadGlobalPlugin it detects all language independent plugins, do categorization, create client and load in memory
func (analyser *Analyser) LoadGlobalPlugin(ctx context.Context, globalPluginPath string) *loadPLugins.GlobalPlugin {
analyser.Setting.Logger.Debug("global plugin loading started")

Expand All @@ -99,6 +108,7 @@ func (analyser *Analyser) LoadGlobalPlugin(ctx context.Context, globalPluginPath
return &plugins
}

//LoadLanguagePlugin it detects all language specific plugins, do categorization, create client and load in memory
func (analyser *Analyser) LoadLanguagePlugin(ctx context.Context, languagePluginPath []*pluginDetails.Language) map[string]*loadPLugins.LanguagePlugin {
analyser.Setting.Logger.Debug("language plugin loading started")

Expand Down
Loading