<commit_before>package org.sonar.LilyPond.checks;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;

import org.sonar.LilyPond.visitors.LilyPondCharsetAwareVisitor;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.SonarException;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.squidbridge.annotations.ActivatedByDefault;
import org.sonar.squidbridge.annotations.SqaleConstantRemediation;
import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;
import org.sonar.squidbridge.checks.SquidCheck;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;

@Rule(
		key = "PageBreakOnRepeatVoltaCheck",
		name = "A page step cannot exist in a repeat volta instruction.",
		description = "Verify that there is no page step in a repeat volta instruction.",
		priority = Priority.MINOR)
		@ActivatedByDefault
		@SqaleSubCharacteristic(RulesDefinition.SubCharacteristics.READABILITY)
		@SqaleConstantRemediation("1min")
public class PageBreakOnRepeatVoltaCheck extends SquidCheck<Grammar> implements LilyPondCharsetAwareVisitor {

	private Charset charset;
	private static final String REPEAT_VOLTA_KEYWORD = "repeat volta";
	private static final String PAGE_BREAK_KEYWORD = "pageBreak";

	public void setCharset(Charset charset) {
	   this.charset = charset;
	}
	
	@Override
	public void visitFile(AstNode node) {
		List<String> lines;
	    try {
	      lines = Files.readLines(getContext().getFile(), charset);
	    } catch (IOException e) {
	      throw new SonarException(e); 
	    }
	    boolean repeatVolta = false;
	    for (int i = 0; i < lines.size(); i++) {
	      String line = lines.get(i);
	      
	      if(line.contains(REPEAT_VOLTA_KEYWORD)) {
	    	  	repeatVolta = true;
	      }
	      
	      if(repeatVolta && line.contains(PAGE_BREAK_KEYWORD)) {
	    	  	getContext().createLineViolation(this, "A page step cannot exist in a repeat volta instruction.", i + 1);
	    	  	repeatVolta = false;
	      }
	    }
	}

}<commit_msg>Adding Lilypond rules (2)<commit_after>package org.sonar.LilyPond.checks;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;

import org.sonar.LilyPond.visitors.LilyPondCharsetAwareVisitor;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.SonarException;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.squidbridge.annotations.ActivatedByDefault;
import org.sonar.squidbridge.annotations.SqaleConstantRemediation;
import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;
import org.sonar.squidbridge.checks.SquidCheck;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;

@Rule(
		key = "PageBreakOnRepeatVoltaCheck",
		name = "A page step cannot exist in a repeat volta instruction.",
		description = "Verify that there is no page step in a repeat volta instruction.",
		priority = Priority.MINOR)
		@ActivatedByDefault
		@SqaleSubCharacteristic(RulesDefinition.SubCharacteristics.READABILITY)
		@SqaleConstantRemediation("1min")
public class PageBreakOnRepeatVoltaCheck extends SquidCheck<Grammar> implements LilyPondCharsetAwareVisitor {

	private Charset charset;
	private static final String REPEAT_VOLTA_KEYWORD = "repeat volta";
	private static final String PAGE_BREAK_KEYWORD = "pageBreak";

	public void setCharset(Charset charset) {
	   this.charset = charset;
	}
	
	@Override
	public void visitFile(AstNode node) {
		List<String> lines;
	    try {
	      lines = Files.readLines(getContext().getFile(), charset);
	    } catch (IOException e) {
	      throw new SonarException(e); 
	    }
	    
	    for (int i = 0; i < lines.size(); i++) {
	      String line = lines.get(i);
	      
	      if(line.contains(REPEAT_VOLTA_KEYWORD) && line.contains(PAGE_BREAK_KEYWORD)) {
	    	  	getContext().createLineViolation(this, "A page step cannot exist in a repeat volta instruction.", i + 1);
	      }
	    }
	}

}
{'fraction_non_alphanumeric': 0.09953190440995319, 'fraction_numerical': 0.0017245627001724563, 'mean_word_length': 4.328083989501312, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6726751', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1309, 'n_words': 285}