Skip to content

Mirror of 437#6

Open
illicitonion wants to merge 4 commits intoCodeYourFuture:mainfrom
illicitonion:mirror-of-437
Open

Mirror of 437#6
illicitonion wants to merge 4 commits intoCodeYourFuture:mainfrom
illicitonion:mirror-of-437

Conversation

@illicitonion
Copy link
Copy Markdown
Member

No description provided.

@illicitonion illicitonion added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. NotCoursework labels Mar 27, 2026
@cyf-ai-code-reviewer
Copy link
Copy Markdown

Thanks for opening a new PR! AI started to review it

Comment on lines +23 to +35
if (showNumbers) {
console.log(`${counterLines++} ${line}`);
} else if (showNonBlankNumbers) {
// increment and show numbers only if the line is not empty.
if (line.trim() !== "") {
console.log(`${counterLines++} ${line}`);
} else {
// print empty lines
console.log(line);
}
} else {
console.log(line);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've noticed that the logic for printing lines with or without numbers is repeated in a few places inside your forEach loop. If you ever wanted to change how lines are printed, you'd have to update it in multiple spots. Can you think of a way to group this logic into a function, so you only have to update it in one place if you want to change how lines are displayed?


//filter the - from the array argv as it's a flag.
const filePaths = argv.filter((arg) => !arg.startsWith("-"));
let counterLines = 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.

The variable 'counterLines' is declared outside your main file loop and is used for numbering lines across all files. Do you want the line numbers to continue across files, or should they reset for each file? If you want them to reset, where could you declare 'counterLines' so it starts from 1 for each file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As other PRs

Comment on lines +23 to +30
const lines = content.split("\n").length - 1;
const words = content
.trim()
.split(/\s+/)
.filter((word) => word != "").length;
// here I used Buffer.byteLength even if characters and bytes can be the same number .length, however sometimes an emoji or special characters can be heavier 2b or 4b
const bytes = Buffer.byteLength(content);
const characters = content.length;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The logic for counting lines, words, bytes, and characters is written inside the forEach loop. If you wanted to use this logic elsewhere, you might have to copy it. Can you think of a way to move this logic into a function that takes the file content and returns these counts?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This seems quite speculative again?

Copy link
Copy Markdown

@cyf-ai-code-reviewer cyf-ai-code-reviewer bot left a comment

Choose a reason for hiding this comment

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

There are many code comment that doesn't provide much value. Could you please check if some comments can be removed, for example comments that just repeat what code does?

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

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. NotCoursework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants