Showing 10 of 57 total issues
Function Prepare
has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring. Open
Open
func Prepare(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) TemplateStruct {
appsMap, libsMap := app.GetTags(ctx, apps, detector)
appsMap = app.AddVersionLibToApp(appsMap, libsMap)
// Sort libraries
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Prepare
has 105 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Prepare(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) TemplateStruct {
appsMap, libsMap := app.GetTags(ctx, apps, detector)
appsMap = app.AddVersionLibToApp(appsMap, libsMap)
// Sort libraries
Function handlerAPI
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func handlerAPI(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Access-Control-Allow-Origin", "*")
githubProv := github.New(github.NewHTTPWrapper(os.Getenv("GITHUB_TOKEN"), 10))
provDetector := providers.NewDetector().AddProvider(githubProv)
depDetector := deps.DefaultDetector()
Function RestoreAsset
has 6 return statements (exceeds 4 allowed). Open
Open
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
Function New
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func New(ctx context.Context, pkg dep_radar.Pkg, branch string, detector dep_radar.IProviderDetector, depDetector dep_radar.IDepDetector) (*App, error) {
Method Detector.Deps
has 5 return statements (exceeds 4 allowed). Open
Open
func (d *Detector) Deps(ctx context.Context, app dep_radar.IApp) (dep_radar.AppDeps, error) {
var (
errs []string
wg sync.WaitGroup
mx sync.Mutex
Function LibsHTML
has 5 return statements (exceeds 4 allowed). Open
Open
func LibsHTML(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) ([]byte, error) {
var buf bytes.Buffer
raw, err := templates.Asset("src/html/templates/libs.html")
if err != nil {
return buf.Bytes(), err
Function Compare
has 5 return statements (exceeds 4 allowed). Open
Open
func Compare(recomends, actual string) (bool, error) {
if recomends == "" || actual == "" {
return false, nil
}
for _, recommended := range strings.Split(recomends, "|") {
Method Client.Get
has 5 return statements (exceeds 4 allowed). Open
Open
func (c *Client) Get(ctx context.Context, uri string) ([]byte, error) {
log.Printf("Start getting url %s\n", uri)
c.limitCh <- struct{}{}
defer func() {
<-c.limitCh
Function AppsHTML
has 5 return statements (exceeds 4 allowed). Open
Open
func AppsHTML(ctx context.Context, apps <-chan dep_radar.IApp, detector *providers.Detector, rec dep_radar.MapRecommended) ([]byte, error) {
var buf bytes.Buffer
raw, err := templates.Asset("src/html/templates/apps.html")
if err != nil {
return buf.Bytes(), err