Skip to content

Commit 83e6545

Browse files
committed
Moving all SVN specific calls to the PHPCS_Diff_SVN_parser class
1 parent 5cdb36f commit 83e6545

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

class-phpcs-diff-svn-parser.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,19 @@ public static function parse_diff_for_info( $diff_file ){
157157

158158
}
159159

160+
public function run_phpcs_for_file_at_revision( $filename, $revision, $phpcs_command, $standards_location, $phpcs_standard ) {
161+
$command_string = sprintf( 'svn cat %s --non-interactive --no-auth-cache --username %s --password %s -r %d | %s --runtime-set installed_paths %s --standard=%s --stdin-path=%s',
162+
escapeshellarg( esc_url_raw( $this->repo_url . $filename ) ),
163+
escapeshellarg( $this->svn_username ),
164+
escapeshellarg( $this->svn_password ),
165+
absint( $revision ),
166+
escapeshellcmd( $phpcs_command ),
167+
escapeshellarg( $standards_location ),
168+
escapeshellarg( $phpcs_standard ),
169+
escapeshellarg( $filename )
170+
);
171+
172+
return shell_exec( $command_string );
173+
}
174+
160175
}

class-phpcs-diff.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
class PHPCS_Diff {
44

5-
// SVN credentials used for checking out individual revisions.
6-
private $svn_username = ''; // @todo: add your SVN username here
7-
private $svn_password = ''; // @todo: add your SVN password here
8-
95
// PHPCS configuration.
106
private $phpcs_command = 'phpcs'; // You might need to provde a path to phpcs.phar file.
117
private $standards_location = '~/PHP_CodeSniffer/Standards'; // @todo: adjust the path to standards
@@ -16,8 +12,6 @@ class PHPCS_Diff {
1612

1713
public $excluded_extensions = array();
1814

19-
public $repo_url = 'https://plugins.svn.wordpress.org/';
20-
2115
public $lines_mapping;
2216

2317
private $phpcs_standard = 'WordPress';
@@ -162,18 +156,8 @@ private function run_phpcs_for_file_revision( $filename, $revision ) {
162156

163157
if ( false === $result ) {
164158

165-
$command_string = sprintf( 'svn cat %s --non-interactive --no-auth-cache --username %s --password %s -r %d | %s --runtime-set installed_paths %s --standard=%s --stdin-path=%s',
166-
escapeshellarg( esc_url_raw( $this->repo_url . $filename ) ),
167-
escapeshellarg( $this->svn_username ),
168-
escapeshellarg( $this->svn_password ),
169-
absint( $revision ),
170-
escapeshellcmd( $this->phpcs_command ),
171-
escapeshellarg( $this->standards_location ),
172-
escapeshellarg( $this->phpcs_standard ),
173-
escapeshellarg( $filename )
174-
);
175-
176-
$result = shell_exec( $command_string );
159+
$result = $this->diff_parser->run_phpcs_for_file_at_revision( $filename, $revision, $this->phpcs_command, $this->standards_location, $this->phpcs_standard );
160+
177161
if ( true !== $this->nocache ) {
178162
wp_cache_set( $cache_key, $result, $cache_group, 6*HOUR_IN_SECONDS );
179163
}

0 commit comments

Comments
 (0)