no_comments 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c98d97eb96221297ef0ef1b6140abd04ac9a54ce759fdfd46b0708497b223022
4
- data.tar.gz: 42a109143ae3b1ab99a176e625a74dbe350d878838eb40b93c5f483f13428f11
3
+ metadata.gz: e8b64729d21c62f938c510fe179a75bdd4e642336830f043e37852351fe2f7e7
4
+ data.tar.gz: 5e36dc7b0751f92f6dba54b42e4f1b89d8612a2ac15e236dbe362e09152b51e5
5
5
  SHA512:
6
- metadata.gz: 82418111acf7d4de92b39c52cd6bafb32959b1ae024836d53a7be3a2b66257cd13299e4b179f84506012debc71db3c48bcbade705e6df0cb18b7a83fa09cc550
7
- data.tar.gz: 01df35d37bc0e4200beb1c15c6b4f2846d2904faa681d20706e218681999e7f4e946ef7df0eab2ede035f415b095d784d06e37ffed15062dc5cbae206e52d510
6
+ metadata.gz: 86877162d04e05f36347fb23b9259064e44acae9b0e9bda4411af13884195b023e909ffbf57dca41b04dfe371ef748d663db22c4fcefd5336d0a3e691addaf58
7
+ data.tar.gz: 0bd8e85a51c4d495aacfa42d8c1c7c755064116761fd56e2a46cc53b14a298bfae65399027daf31dc93a537a5ff64e52bf88f9414be67a10efb91ccac6510a7c
data/AGENTS.md ADDED
@@ -0,0 +1,48 @@
1
+ # Instructions
2
+ - The user will provide a task.
3
+ - The task involves working with Git repositories in your current working directory.
4
+ - Wait for all terminal commands to be completed (or terminate them) before finishing.
5
+
6
+ # Git instructions
7
+ If completing the user's task requires writing or modifying files:
8
+ - Do not create new branches.
9
+ - Use git to commit your changes.
10
+ - If pre-commit fails, fix issues and retry.
11
+ - Check git status to confirm your commit. You must leave your worktree in a clean state.
12
+ - Only committed code will be evaluated.
13
+ - Do not modify or amend existing commits.
14
+
15
+ # AGENTS.md spec
16
+ - Containers often contain AGENTS.md files. These files can appear anywhere in the container's filesystem. Typical locations include `/`, `~`, and in various places inside of Git repos.
17
+ - These files are a way for humans to give you (the agent) instructions or tips for working within the container.
18
+ - Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.
19
+ - AGENTS.md files may provide instructions about PR messages (messages attached to a GitHub Pull Request produced by the agent, describing the PR). These instructions should be respected.
20
+ - Instructions in AGENTS.md files:
21
+ - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.
22
+ - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.
23
+ - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.
24
+ - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.
25
+ - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.
26
+ - AGENTS.md files need not live only in Git repos. For example, you may find one in your home directory.
27
+ - If the AGENTS.md includes programmatic checks to verify your work, you MUST run all of them and make a best effort to validate that the checks pass AFTER all code changes have been made.
28
+ - This applies even for changes that appear simple, i.e. documentation. You still must run all of the programmatic checks.
29
+
30
+ # Citations instructions
31
+ - If you browsed files or used terminal commands, you must add citations to the final response (not the body of the PR message) where relevant. Citations reference file paths and terminal outputs with the following formats:
32
+ 1) `F:<file_path>†L<line_start>(-L<line_end>)?`
33
+ - File path citations must start with `F:`. `file_path` is the exact file path of the file relative to the root of the repository that contains the relevant text.
34
+ - `line_start` is the 1-indexed start line number of the relevant output within that file.
35
+ 2) `<chunk_id>†L<line_start>(-L<line_end>)?`
36
+ - Where chunk_id is the chunk_id of the terminal output, line_start and line_end are the 1-indexed start and end line numbers of the relevant output within that chunk.
37
+ - Line ends are optional, and if not provided, line end is the same as line start, so only 1 line is cited.
38
+ - Ensure that the line numbers are correct, and that the cited file paths or terminal outputs are directly relevant to the word or clause before the citation.
39
+ - Do not cite completely empty lines inside the chunk, only cite lines that have content.
40
+ - Only cite from file paths and terminal outputs, DO NOT cite from previous pr diffs and comments, nor cite git hashes as chunk ids.
41
+ - Use file path citations that reference any code changes, documentation or files, and use terminal citations only for relevant terminal output.
42
+ - Prefer file citations over terminal citations unless the terminal output is directly relevant to the clauses before the citation, i.e. clauses on test results.
43
+ - For PR creation tasks, use file citations when referring to code changes in the summary section of your final response, and terminal citations in the testing section.
44
+ - For question-answering tasks, you should only use terminal citations if you need to programmatically verify an answer (i.e. counting lines of code). Otherwise, use file citations.
45
+
46
+ Add the crucial information that the branch name should be written in english if not please translate it into english.
47
+
48
+ Before commit run 'bundle exec rspec' 'bundle exec bundler-audit --update' and 'bundle exec rubocop --parallel' and the next fix the problems if appear
@@ -5,6 +5,8 @@ module NoComments
5
5
  MAGIC_COMMENT_REGEX = /\A#.*\b(?:frozen_string_literal|encoding|coding|warn_indent|fileencoding)\b.*\z/
6
6
  TOOL_COMMENT_REGEX = /\A#\s*(?:rubocop|reek|simplecov|coveralls|pry|byebug|noinspection|sorbet|type)\b/
7
7
  DOC_COMMENT_REGEX = /\A#\s*@\w+/
8
+ NODOC_STRING = ":nodoc:"
9
+ CLASS_OR_MODULE_REGEX = /\A(?:class|module)\b/
8
10
  def magic_comment?(stripped_line)
9
11
  stripped_line.match?(MAGIC_COMMENT_REGEX)
10
12
  end
@@ -13,8 +15,12 @@ module NoComments
13
15
  stripped_line.match?(TOOL_COMMENT_REGEX)
14
16
  end
15
17
 
16
- def documentation_comment?(stripped_line)
17
- stripped_line.match?(DOC_COMMENT_REGEX)
18
+ def documentation_comment?(stripped_line, next_line = nil)
19
+ return true if stripped_line.match?(DOC_COMMENT_REGEX)
20
+ return true if stripped_line.include?(NODOC_STRING)
21
+ return true if next_line&.match?(CLASS_OR_MODULE_REGEX)
22
+
23
+ false
18
24
  end
19
25
  end
20
26
  end
@@ -20,41 +20,42 @@ module NoComments
20
20
 
21
21
  def process(content)
22
22
  lines = content.lines
23
- lines.each do |line|
24
- @line_number += 1
23
+ lines.each_with_index do |line, index|
24
+ @line_number = index + 1
25
25
  stripped_line = line.strip
26
- process_line(line, stripped_line)
26
+ next_line = next_non_comment_line(lines, index)
27
+ process_line(line, stripped_line, next_line)
27
28
  end
28
29
  cleaned_content = @result_lines.join("\n")
29
30
  cleaned_content += "\n" unless cleaned_content.empty?
30
31
  [cleaned_content, @comments]
31
32
  end
32
33
 
33
- def process_line(line, stripped_line)
34
+ def process_line(line, stripped_line, next_line)
34
35
  if @in_multiline_comment
35
36
  handle_multiline_comment(stripped_line)
36
37
  elsif @in_heredoc
37
38
  handle_heredoc(line, stripped_line)
38
39
  elsif !@code_started
39
- handle_initial_lines(line, stripped_line)
40
+ handle_initial_lines(line, stripped_line, next_line)
40
41
  else
41
- handle_regular_line(line, stripped_line)
42
+ handle_regular_line(line, stripped_line, next_line)
42
43
  end
43
44
  end
44
45
 
45
- def handle_initial_lines(line, stripped_line)
46
+ def handle_initial_lines(line, stripped_line, next_line)
46
47
  if stripped_line.empty? || stripped_line.start_with?("#!") || magic_comment?(stripped_line)
47
48
  @result_lines << line.rstrip
48
49
  elsif stripped_line.start_with?("#")
49
- handle_initial_comment_line(line, stripped_line)
50
+ handle_initial_comment_line(line, stripped_line, next_line)
50
51
  else
51
52
  @code_started = true
52
- handle_regular_line(line, stripped_line)
53
+ handle_regular_line(line, stripped_line, next_line)
53
54
  end
54
55
  end
55
56
 
56
- def handle_initial_comment_line(line, stripped_line)
57
- if tool_comment?(stripped_line) || (@keep_doc_comments && documentation_comment?(stripped_line))
57
+ def handle_initial_comment_line(line, stripped_line, next_line)
58
+ if tool_comment?(stripped_line) || (@keep_doc_comments && documentation_comment?(stripped_line, next_line&.strip))
58
59
  @result_lines << line.rstrip
59
60
  else
60
61
  @comments << [@line_number, stripped_line]
@@ -73,19 +74,21 @@ module NoComments
73
74
  )
74
75
  end
75
76
 
76
- def handle_regular_line(line, stripped_line)
77
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
78
+ def handle_regular_line(line, stripped_line, next_line)
77
79
  if stripped_line == "=begin"
78
80
  start_multiline_comment(stripped_line)
79
81
  elsif (heredoc_start = detect_heredoc_start(line))
80
82
  start_heredoc(line, heredoc_start)
81
83
  elsif stripped_line.start_with?("#") &&
82
84
  (tool_comment?(stripped_line) ||
83
- (@keep_doc_comments && documentation_comment?(stripped_line)))
85
+ (@keep_doc_comments && documentation_comment?(stripped_line, next_line&.strip)))
84
86
  @result_lines << line.rstrip
85
87
  else
86
88
  process_code_line(line)
87
89
  end
88
90
  end
91
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
89
92
 
90
93
  def start_multiline_comment(stripped_line)
91
94
  @in_multiline_comment = true
@@ -113,6 +116,19 @@ module NoComments
113
116
 
114
117
  private
115
118
 
119
+ def next_non_comment_line(lines, index)
120
+ j = index + 1
121
+ while j < lines.length
122
+ line = lines[j]
123
+ stripped = line.strip
124
+ return nil if stripped.empty?
125
+ return line unless stripped.start_with?("#")
126
+
127
+ j += 1
128
+ end
129
+ nil
130
+ end
131
+
116
132
  def handle_empty_line(line)
117
133
  @result_lines << line.rstrip
118
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NoComments
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: no_comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justyna
@@ -18,6 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - ".rspec"
20
20
  - ".rubocop.yml"
21
+ - AGENTS.md
21
22
  - LICENSE
22
23
  - README.md
23
24
  - Rakefile