Skip to content

Backup/main before prs#5

Open
yagreut wants to merge 12 commits into
mainfrom
backup/main-before-prs
Open

Backup/main before prs#5
yagreut wants to merge 12 commits into
mainfrom
backup/main-before-prs

Conversation

@yagreut

@yagreut yagreut commented Apr 16, 2025

Copy link
Copy Markdown
Owner

Mini repository scanner. Prompts user for file name and content. Saves the content into a file with the required name in a json format. The scanner clones the repo into a temp folder, scans it and returns a json list of the files in the repository that are bigger than a certain size.

Comment thread main.go
Comment thread main.go Outdated
Comment thread scanner.go Outdated
Comment on lines +26 to +29
err = cmd.Run()
if err != nil {
return "", err
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a function returns a single output and this output is checked in an if (and only in this if) it should be one line:

if err = cmd.Run(); err != nil {
	return "", err
}

This is a common pattern in error handling

Comment thread scanner.go Outdated
Comment thread main.go Outdated
Comment thread scanner.go Outdated
Comment thread scanner.go Outdated
Comment thread scanner.go Outdated
Comment thread scanner.go Outdated
Comment thread scanner.go Outdated
Comment thread service/service.go
if err != nil {
return nil, err
}
defer os.RemoveAll(repoDir)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid saving unnecessary data on my computer.
I'm making sure that all the cloned data is being erased when I'm done with it.

Comment thread service/service.go
Comment thread repository/repository.go
@@ -0,0 +1,20 @@
package repository

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose this name?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is the file that is in charge of communicating with the data,
from what I know the layer that is accessing the data is the repository layer.

Comment thread main.go
"github.com/yagreut/onboardingAssignment/repository"
"github.com/yagreut/onboardingAssignment/service"

"github.com/sirupsen/logrus"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose this logger?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have compared it against 2 more popular loggers and this one was both user friendly and met the assignment's demands.

Comment thread main.go
logrus.Fatal("Usage: go run main.go <input_file.json>")
}

inputFile := os.Args[1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's enhance the task - add a secret scanning capability:
For each file, except for the large files, search whether it contains a GitHub Token.
Explore how to do it :)
If something is not clear, please ask

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants